[llvm] f71a3b5 - [InstCombine] add tests for diff-of-sums; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 9 12:33:49 PDT 2020


Author: Sanjay Patel
Date: 2020-06-09T15:33:38-04:00
New Revision: f71a3b54f0c5c300440c5ce21c76b5f7f41fc626

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

LOG: [InstCombine] add tests for diff-of-sums; NFC

Added: 
    llvm/test/Transforms/InstCombine/vector-reductions.ll

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/vector-reductions.ll b/llvm/test/Transforms/InstCombine/vector-reductions.ll
new file mode 100644
index 000000000000..5eac0e09414c
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/vector-reductions.ll
@@ -0,0 +1,75 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -instcombine -S | FileCheck %s
+
+declare float @llvm.experimental.vector.reduce.v2.fadd.f32.v4f32(float, <4 x float>)
+declare float @llvm.experimental.vector.reduce.v2.fadd.f32.v8f32(float, <8 x float>)
+declare void @use_f32(float)
+
+define float @
diff _of_sums_v4f32(float %a0, <4 x float> %v0, float %a1, <4 x float> %v1) {
+; CHECK-LABEL: @
diff _of_sums_v4f32(
+; CHECK-NEXT:    [[R0:%.*]] = call float @llvm.experimental.vector.reduce.v2.fadd.f32.v4f32(float [[A0:%.*]], <4 x float> [[V0:%.*]])
+; CHECK-NEXT:    [[R1:%.*]] = call float @llvm.experimental.vector.reduce.v2.fadd.f32.v4f32(float [[A1:%.*]], <4 x float> [[V1:%.*]])
+; CHECK-NEXT:    [[R:%.*]] = fsub reassoc nsz float [[R0]], [[R1]]
+; CHECK-NEXT:    ret float [[R]]
+;
+  %r0 = call float @llvm.experimental.vector.reduce.v2.fadd.f32.v4f32(float %a0, <4 x float> %v0)
+  %r1 = call float @llvm.experimental.vector.reduce.v2.fadd.f32.v4f32(float %a1, <4 x float> %v1)
+  %r = fsub reassoc nsz float %r0, %r1
+  ret float %r
+}
+
+define float @
diff _of_sums_v4f32_fmf(float %a0, <4 x float> %v0, float %a1, <4 x float> %v1) {
+; CHECK-LABEL: @
diff _of_sums_v4f32_fmf(
+; CHECK-NEXT:    [[R0:%.*]] = call fast float @llvm.experimental.vector.reduce.v2.fadd.f32.v4f32(float [[A0:%.*]], <4 x float> [[V0:%.*]])
+; CHECK-NEXT:    [[R1:%.*]] = call fast float @llvm.experimental.vector.reduce.v2.fadd.f32.v4f32(float [[A1:%.*]], <4 x float> [[V1:%.*]])
+; CHECK-NEXT:    [[R:%.*]] = fsub nnan ninf nsz float [[R0]], [[R1]]
+; CHECK-NEXT:    ret float [[R]]
+;
+  %r0 = call fast float @llvm.experimental.vector.reduce.v2.fadd.f32.v4f32(float %a0, <4 x float> %v0)
+  %r1 = call fast float @llvm.experimental.vector.reduce.v2.fadd.f32.v4f32(float %a1, <4 x float> %v1)
+  %r = fsub ninf nnan nsz float %r0, %r1
+  ret float %r
+}
+
+define float @
diff _of_sums_extra_use1(float %a0, <4 x float> %v0, float %a1, <4 x float> %v1) {
+; CHECK-LABEL: @
diff _of_sums_extra_use1(
+; CHECK-NEXT:    [[R0:%.*]] = call fast float @llvm.experimental.vector.reduce.v2.fadd.f32.v4f32(float [[A0:%.*]], <4 x float> [[V0:%.*]])
+; CHECK-NEXT:    call void @use_f32(float [[R0]])
+; CHECK-NEXT:    [[R1:%.*]] = call fast float @llvm.experimental.vector.reduce.v2.fadd.f32.v4f32(float [[A1:%.*]], <4 x float> [[V1:%.*]])
+; CHECK-NEXT:    [[R:%.*]] = fsub fast float [[R0]], [[R1]]
+; CHECK-NEXT:    ret float [[R]]
+;
+  %r0 = call fast float @llvm.experimental.vector.reduce.v2.fadd.f32.v4f32(float %a0, <4 x float> %v0)
+  call void @use_f32(float %r0)
+  %r1 = call fast float @llvm.experimental.vector.reduce.v2.fadd.f32.v4f32(float %a1, <4 x float> %v1)
+  %r = fsub fast float %r0, %r1
+  ret float %r
+}
+
+define float @
diff _of_sums_extra_use2(float %a0, <4 x float> %v0, float %a1, <4 x float> %v1) {
+; CHECK-LABEL: @
diff _of_sums_extra_use2(
+; CHECK-NEXT:    [[R0:%.*]] = call fast float @llvm.experimental.vector.reduce.v2.fadd.f32.v4f32(float [[A0:%.*]], <4 x float> [[V0:%.*]])
+; CHECK-NEXT:    [[R1:%.*]] = call fast float @llvm.experimental.vector.reduce.v2.fadd.f32.v4f32(float [[A1:%.*]], <4 x float> [[V1:%.*]])
+; CHECK-NEXT:    call void @use_f32(float [[R1]])
+; CHECK-NEXT:    [[R:%.*]] = fsub fast float [[R0]], [[R1]]
+; CHECK-NEXT:    ret float [[R]]
+;
+  %r0 = call fast float @llvm.experimental.vector.reduce.v2.fadd.f32.v4f32(float %a0, <4 x float> %v0)
+  %r1 = call fast float @llvm.experimental.vector.reduce.v2.fadd.f32.v4f32(float %a1, <4 x float> %v1)
+  call void @use_f32(float %r1)
+  %r = fsub fast float %r0, %r1
+  ret float %r
+}
+
+define float @
diff _of_sums_type_mismatch(float %a0, <4 x float> %v0, float %a1, <8 x float> %v1) {
+; CHECK-LABEL: @
diff _of_sums_type_mismatch(
+; CHECK-NEXT:    [[R0:%.*]] = call fast float @llvm.experimental.vector.reduce.v2.fadd.f32.v4f32(float [[A0:%.*]], <4 x float> [[V0:%.*]])
+; CHECK-NEXT:    [[R1:%.*]] = call fast float @llvm.experimental.vector.reduce.v2.fadd.f32.v8f32(float [[A1:%.*]], <8 x float> [[V1:%.*]])
+; CHECK-NEXT:    [[R:%.*]] = fsub fast float [[R0]], [[R1]]
+; CHECK-NEXT:    ret float [[R]]
+;
+  %r0 = call fast float @llvm.experimental.vector.reduce.v2.fadd.f32.v4f32(float %a0, <4 x float> %v0)
+  %r1 = call fast float @llvm.experimental.vector.reduce.v2.fadd.f32.v8f32(float %a1, <8 x float> %v1)
+  %r = fsub fast float %r0, %r1
+  ret float %r
+}


        


More information about the llvm-commits mailing list