Closed
Description
I tried this code:
#![feature(asm)]
#[inline(always)]
fn check_bsf() -> (u64, u8) {
let flags: u8;
let result: u64;
unsafe {
asm!(
"bsf rbx, rbx",
"lahf",
inout("rbx") 0u64 => result,
out("ah") flags,
options(nostack, nomem),
);
}
return (result, flags);
}
fn main() {
let flags1: u8;
unsafe {
asm!("lahf", out("ah") flags1, options(nostack, nomem));
}
let (result, flags2) = check_bsf();
let flagsdiff = flags2 ^ flags1;
let zero_flag = 1 << 6;
println!("result={}", result);
assert_eq!(flagsdiff, zero_flag);
}
I expected to see this happen:
The code compiles, like with opt-level
0 or 1
Instead, this happened:
When compiling with opt-level
2 or 3, just this message appears
LLVM ERROR: Cannot encode high byte register in REX-prefixed instruction
Meta
rustc --version --verbose
:
rustc 1.53.0-nightly (07e0e2ec2 2021-03-24)
binary: rustc
commit-hash: 07e0e2ec268c140e607e1ac7f49f145612d0f597
commit-date: 2021-03-24
host: x86_64-unknown-linux-gnu
release: 1.53.0-nightly
LLVM version: 12.0.0
No backtrace