Function bitintr::x86::bmi2::bzhi [] [src]

pub fn bzhi<T: Int>(x: T, bit_position: T) -> T

Zero the high bits of x at position >= bit_position.

Panics

If bit_position >= bit_size() the behavior is undefined (panics in debug builds).

Assembly Instructions

  • BZHI:
    • Description: Zero high bits starting with specified bit position.
    • Architecture: x86.
    • Instruction set: BMI2.
    • Registers: 32/64 bit.

Example

use bitintr::x86::bmi2::*;

let n = 0b1111_0010u32;
let s = 0b0001_0010u32;
assert_eq!(bzhi(n, 5), s);
assert_eq!(n.bzhi(5), s);