[llvm] 1017811 - [RISCV] Add test case showing failure to fold (fadd (reduce -0.0, X), Y) due to one use check. NFC"

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 25 12:56:26 PDT 2023


Author: Craig Topper
Date: 2023-04-25T12:52:21-07:00
New Revision: 10178117765c961cf0551bb1496af4aa14530173

URL: https://github.com/llvm/llvm-project/commit/10178117765c961cf0551bb1496af4aa14530173
DIFF: https://github.com/llvm/llvm-project/commit/10178117765c961cf0551bb1496af4aa14530173.diff

LOG: [RISCV] Add test case showing failure to fold (fadd (reduce -0.0, X), Y) due to one use check. NFC"

If the -0.0 has multiple uses we won't fold the reduction.

Added: 
    

Modified: 
    llvm/test/CodeGen/RISCV/rvv/fold-binary-reduce.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/CodeGen/RISCV/rvv/fold-binary-reduce.ll b/llvm/test/CodeGen/RISCV/rvv/fold-binary-reduce.ll
index ade42472db87..058263f01d5f 100644
--- a/llvm/test/CodeGen/RISCV/rvv/fold-binary-reduce.ll
+++ b/llvm/test/CodeGen/RISCV/rvv/fold-binary-reduce.ll
@@ -278,6 +278,28 @@ entry:
   ret float %res
 }
 
+define float @reduce_fadd4(float %x, float %y, <4 x float> %v, <4 x float> %w) {
+; CHECK-LABEL: reduce_fadd4:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:    vsetivli zero, 4, e32, m1, ta, ma
+; CHECK-NEXT:    vmv.s.x v10, zero
+; CHECK-NEXT:    vfredusum.vs v8, v8, v10
+; CHECK-NEXT:    vfmv.f.s fa5, v8
+; CHECK-NEXT:    vfredusum.vs v8, v9, v10
+; CHECK-NEXT:    vfmv.f.s fa4, v8
+; CHECK-NEXT:    fadd.s fa5, fa5, fa0
+; CHECK-NEXT:    fadd.s fa4, fa4, fa1
+; CHECK-NEXT:    fdiv.s fa0, fa5, fa4
+; CHECK-NEXT:    ret
+entry:
+  %rdx = call fast float @llvm.vector.reduce.fadd.v4f32(float -0.0, <4 x float> %v)
+  %rdx2 = call fast float @llvm.vector.reduce.fadd.v4f32(float -0.0, <4 x float> %w)
+  %res = fadd fast float %rdx, %x
+  %res2 = fadd fast float %rdx2, %y
+  %div = fdiv fast float %res, %res2
+  ret float %div
+}
+
 define float @reduce_fmax(float %x, <4 x float> %v) {
 ; CHECK-LABEL: reduce_fmax:
 ; CHECK:       # %bb.0: # %entry


        


More information about the llvm-commits mailing list