[llvm] [KnownFPClass] Improve KnownFPClass::toKnownBits deductions for IEEE types (PR #223204)
Eric Ross via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 13 17:10:14 PDT 2026
================
@@ -261,25 +435,70 @@ if.else:
ret i1 false
}
-define i32 @test_snan_only(float nofpclass(qnan sub norm zero inf) %x) {
+define i32 @test_snan_only(float nofpclass(qnan inf zero norm sub) %x) {
; CHECK-LABEL: @test_snan_only(
+; CHECK-NEXT: ret i32 2139095040
+;
+ %y = bitcast float %x to i32
+ %and = and i32 %y, u0x7FC00000
+ ret i32 %and
+}
+
+define i32 @test_qnan_only(float nofpclass(snan inf zero norm sub) %x) {
+; CHECK-LABEL: @test_qnan_only(
+; CHECK-NEXT: ret i32 2143289344
+;
+ %y = bitcast float %x to i32
+ %and = and i32 %y, u0x7FC00000
+ ret i32 %and
+}
+
+define i32 @test_nan_only_include_quiet_bit(float nofpclass(inf zero norm sub) %x) {
+; CHECK-LABEL: @test_nan_only_include_quiet_bit(
; CHECK-NEXT: [[Y:%.*]] = bitcast float [[X:%.*]] to i32
-; CHECK-NEXT: [[AND:%.*]] = and i32 [[Y]], 4194304
+; CHECK-NEXT: [[AND:%.*]] = and i32 [[Y]], 2143289344
; CHECK-NEXT: ret i32 [[AND]]
;
%y = bitcast float %x to i32
- %and = and i32 %y, 4194304
+ %and = and i32 %y, u0x7FC00000
ret i32 %and
}
-define i32 @test_qnan_only(float nofpclass(snan sub norm zero inf) %x) {
----------------
ZERICO2005 wrote:
The original `test_qnan_only` was renamed to `test_f32_quiet_bit_set`.
The original `test_snan_only` has been replaced by `test_f32_quiet_bit_clear`. I think this is fine, because `test_f32_quiet_bit_clear` is able to make the exact same deductions with more limited `nofpclass` information (`nofpclass(qnan norm sub)` versus `nofpclass(qnan inf zero norm sub)`.
https://github.com/llvm/llvm-project/pull/223204
More information about the llvm-commits
mailing list