Closed
Description
From rust-lang/rust#131162:
const MASK: u8 = 1;
#[no_mangle]
pub fn test1(a1: u8, a2: u8) -> bool {
(a1 & !MASK) == (a2 & !MASK) && (a1 & MASK) == (a2 & MASK)
}
https://llvm.godbolt.org/z/Pasonhe9d:
define i1 @test(i8 %a1, i8 %a2) {
%xor = xor i8 %a1, %a2
%cmp = icmp ult i8 %xor, 2
%lobit = trunc i8 %xor to i1
%lobit.inv = xor i1 %lobit, true
%and = and i1 %cmp, %lobit.inv
ret i1 %and
}
LLVM 18:
define i1 @test(i8 %a1, i8 %a2) {
%and = icmp eq i8 %a1, %a2
ret i1 %and
}
LLVM 19:
define i1 @test(i8 %a1, i8 %a2) {
%xor = xor i8 %a1, %a2
%cmp = icmp ult i8 %xor, 2
%lobit = trunc i8 %xor to i1
%lobit.inv = xor i1 %lobit, true
%and = and i1 %cmp, %lobit.inv
ret i1 %and
}
I believe this is fallout from removal of the trunc i1 canonicalization in #84628.