[clang] [llvm] [ValueTracking] use KnownBits to compute fpclass from bitcast (PR #97762)

Yingwei Zheng via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 5 19:05:23 PDT 2024


================
@@ -1549,30 +1549,10 @@ define amdgpu_kernel void @multiple_uses_fneg_select_f64(double %x, double %y, i
 define amdgpu_kernel void @fnge_select_f32_multi_use_regression(float %.i2369) {
 ; GCN-LABEL: fnge_select_f32_multi_use_regression:
 ; GCN:       ; %bb.0: ; %.entry
-; GCN-NEXT:    s_load_dword s0, s[4:5], 0x0
-; GCN-NEXT:    s_waitcnt lgkmcnt(0)
-; GCN-NEXT:    v_cmp_nlt_f32_e64 s[0:1], s0, 0
-; GCN-NEXT:    v_cndmask_b32_e64 v0, 0, 1, s[0:1]
-; GCN-NEXT:    v_cmp_ngt_f32_e32 vcc, 0, v0
-; GCN-NEXT:    v_cndmask_b32_e32 v1, 0, v0, vcc
-; GCN-NEXT:    v_mul_f32_e64 v0, -v0, v1
-; GCN-NEXT:    v_cmp_lt_f32_e32 vcc, 0, v0
-; GCN-NEXT:    s_and_b64 vcc, exec, vcc
----------------
dtcxzyw wrote:

Looks like all instructions are removed by DCE. Can you fix this (in a separate PR) test by adding a user with side effect?
```
define amdgpu_kernel void @fnge_select_f32_multi_use_regression(float %.i2369, ptr addrspace(1) %dst) {
   .entry:
   %i = fcmp uge float %.i2369, 0.000000e+00
  %.i2379 = select i1 %i, i32 1, i32 0
  %.i0436 = bitcast i32 %.i2379 to float
  %.i0440 = fneg float %.i0436
  %i1 = fcmp uge float %.i0436, 0.000000e+00
  %.i2495 = select i1 %i1, i32 %.i2379, i32 0
  %.i0552 = bitcast i32 %.i2495 to float
  %.i0592 = fmul float %.i0440, %.i0552
  %.i0721 = fcmp ogt float %.i0592, 0.000000e+00
  br i1 %.i0721, label %bb5, label %bb
bb:                                               ; preds = %.entry
  %i2 = call <2 x i32> @llvm.amdgcn.s.buffer.load.v2i32(<4 x i32> zeroinitializer, i32 1, i32 0)
  %i3 = shufflevector <2 x i32> %i2, <2 x i32> zeroinitializer, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
  %i4 = bitcast <4 x i32> %i3 to <4 x float>
  %.i0753 = extractelement <4 x float> %i4, i64 0
  store float %.i0753, ptr addrspace(1) %dst
  br label %bb5
bb5:                                              ; preds = %bb, %.entry
  ret void
}
```

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


More information about the cfe-commits mailing list