[llvm] 0590502 - [InstCombine][test] add tests for fadd reductions; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 18 03:32:13 PDT 2021
Author: Sanjay Patel
Date: 2021-07-18T06:26:20-04:00
New Revision: 059050226532d633199f33c5df19b7e9eeccbf22
URL: https://github.com/llvm/llvm-project/commit/059050226532d633199f33c5df19b7e9eeccbf22
DIFF: https://github.com/llvm/llvm-project/commit/059050226532d633199f33c5df19b7e9eeccbf22.diff
LOG: [InstCombine][test] add tests for fadd reductions; NFC
Added:
Modified:
llvm/test/Transforms/InstCombine/fadd.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/fadd.ll b/llvm/test/Transforms/InstCombine/fadd.ll
index 65c2f605cf39a..d3a35ffa2e7fc 100644
--- a/llvm/test/Transforms/InstCombine/fadd.ll
+++ b/llvm/test/Transforms/InstCombine/fadd.ll
@@ -3,6 +3,7 @@
declare void @use(float)
declare void @use_vec(<2 x float>)
+declare float @llvm.vector.reduce.fadd.v4f32(float, <4 x float>)
; -x + y => y - x
@@ -387,3 +388,73 @@ define float @fmul_fneg2_extra_use3(float %x, float %py, float %z) {
%r = fadd float %mul, %z
ret float %r
}
+
+define float @fadd_rdx(float %x, <4 x float> %v) {
+; CHECK-LABEL: @fadd_rdx(
+; CHECK-NEXT: [[RDX:%.*]] = call fast float @llvm.vector.reduce.fadd.v4f32(float 0.000000e+00, <4 x float> [[V:%.*]])
+; CHECK-NEXT: [[ADD:%.*]] = fadd fast float [[RDX]], [[X:%.*]]
+; CHECK-NEXT: ret float [[ADD]]
+;
+ %rdx = call fast float @llvm.vector.reduce.fadd.v4f32(float 0.0, <4 x float> %v)
+ %add = fadd fast float %rdx, %x
+ ret float %add
+}
+
+define float @fadd_rdx_commute(float %x, <4 x float> %v) {
+; CHECK-LABEL: @fadd_rdx_commute(
+; CHECK-NEXT: [[D:%.*]] = fdiv float 4.200000e+01, [[X:%.*]]
+; CHECK-NEXT: [[RDX:%.*]] = call float @llvm.vector.reduce.fadd.v4f32(float -0.000000e+00, <4 x float> [[V:%.*]])
+; CHECK-NEXT: [[ADD:%.*]] = fadd reassoc nsz float [[D]], [[RDX]]
+; CHECK-NEXT: ret float [[ADD]]
+;
+ %d = fdiv float 42.0, %x
+ %rdx = call float @llvm.vector.reduce.fadd.v4f32(float -0.0, <4 x float> %v)
+ %add = fadd reassoc nsz float %d, %rdx
+ ret float %add
+}
+
+define float @fadd_rdx_fmf(float %x, <4 x float> %v) {
+; CHECK-LABEL: @fadd_rdx_fmf(
+; CHECK-NEXT: [[RDX:%.*]] = call float @llvm.vector.reduce.fadd.v4f32(float 0.000000e+00, <4 x float> [[V:%.*]])
+; CHECK-NEXT: [[ADD:%.*]] = fadd reassoc float [[RDX]], [[X:%.*]]
+; CHECK-NEXT: ret float [[ADD]]
+;
+ %rdx = call float @llvm.vector.reduce.fadd.v4f32(float 0.0, <4 x float> %v)
+ %add = fadd reassoc float %rdx, %x
+ ret float %add
+}
+
+define float @fadd_rdx_extra_use(float %x, <4 x float> %v) {
+; CHECK-LABEL: @fadd_rdx_extra_use(
+; CHECK-NEXT: [[RDX:%.*]] = call float @llvm.vector.reduce.fadd.v4f32(float 0.000000e+00, <4 x float> [[V:%.*]])
+; CHECK-NEXT: call void @use(float [[RDX]])
+; CHECK-NEXT: [[ADD:%.*]] = fadd fast float [[RDX]], [[X:%.*]]
+; CHECK-NEXT: ret float [[ADD]]
+;
+ %rdx = call float @llvm.vector.reduce.fadd.v4f32(float 0.0, <4 x float> %v)
+ call void @use(float %rdx)
+ %add = fadd fast float %rdx, %x
+ ret float %add
+}
+
+define float @fadd_rdx_nonzero_start_const_op(<4 x float> %v) {
+; CHECK-LABEL: @fadd_rdx_nonzero_start_const_op(
+; CHECK-NEXT: [[RDX:%.*]] = call float @llvm.vector.reduce.fadd.v4f32(float 4.200000e+01, <4 x float> [[V:%.*]])
+; CHECK-NEXT: [[ADD:%.*]] = fadd reassoc ninf nsz float [[RDX]], -9.000000e+00
+; CHECK-NEXT: ret float [[ADD]]
+;
+ %rdx = call float @llvm.vector.reduce.fadd.v4f32(float 42.0, <4 x float> %v)
+ %add = fadd reassoc nsz ninf float %rdx, -9.0
+ ret float %add
+}
+
+define float @fadd_rdx_nonzero_start_variable_op(float %x, <4 x float> %v) {
+; CHECK-LABEL: @fadd_rdx_nonzero_start_variable_op(
+; CHECK-NEXT: [[RDX:%.*]] = call float @llvm.vector.reduce.fadd.v4f32(float 4.200000e+01, <4 x float> [[V:%.*]])
+; CHECK-NEXT: [[ADD:%.*]] = fadd fast float [[RDX]], [[X:%.*]]
+; CHECK-NEXT: ret float [[ADD]]
+;
+ %rdx = call float @llvm.vector.reduce.fadd.v4f32(float 42.0, <4 x float> %v)
+ %add = fadd fast float %rdx, %x
+ ret float %add
+}
More information about the llvm-commits
mailing list