[llvm] [InstCombine] Generalize fold of `fcmp + copysign` (PR #86387)

Andy Kaylor via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 25 12:23:48 PDT 2024


================
@@ -736,6 +728,54 @@ define i1 @is_signbit_set_simplify_nan(double %x) {
   ret i1 %r
 }
 
+define i1 @test_oeq(float %a) {
----------------
andykaylor wrote:

In the discussion of the original transformation, there seemed to be some concern about zeros and NaNs (as reflected in the original implementation), but there were no specific cases cited. I don't see what the problem would be, but maybe you should add a couple of test cases here to show that it's OK.

```
; Returns false
define i1 @test_oeq_nan(float %a) {
entry:
  %res = call float @llvm.copysign.f32(float 0x7FF8000000000000, float %a)
  %cmp = fcmp oeq float %res, 1.0
  ret i1 %cmp
}

; Returns true
define i1 @test_uno_nan(float %a) {
entry:
  %res = call float @llvm.copysign.f32(float 0x7FF8000000000000, float %a)
  %cmp = fcmp uno float %res, 1.0
  ret i1 %cmp
}

; Returns false
define i1 @test_oge_zero(float %a) {
entry:
  %res = call float @llvm.copysign.f32(float 0.0, float %a)
  %cmp = fcmp oge float %res, 1.0
  ret i1 %cmp
}

```



https://github.com/llvm/llvm-project/pull/86387


More information about the llvm-commits mailing list