llvm-project
llvm-project copied to clipboard
Instcombine incorrectly optimizes `fcmp uno`
After this commit: https://github.com/llvm/llvm-project/commit/e47b76a82a0300900dbf3c2d3a50552a76305a8c running opt -passes=instcombine on the following IR:
define i1 @test(i64 %arg) {
%sitofp = sitofp i64 %arg to float
%fmul = fmul float %sitofp, 0x7FF0000000000000
%fcmp = fcmp uno float %fmul, 0.000000e+00
ret i1 %fcmp
}
results in
define i1 @test(i64 %arg) {
ret i1 false
}
That's not correct because fcmp uno returns true if either argument is NaN and by IEEE-754 multiplication of infinity (aka 0x7FF0000000000000) and 0 (sitofp i64 %arg to float with %arg == 0) is NaN. Alive2 points out exactly this case: https://alive2.llvm.org/ce/z/5rPFgH
https://reviews.llvm.org/D152957
Not sure why it didn't auto-close after the commit