[llvm] bb448a2 - [SLP] Add test where reduction result is used in PHI.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 2 05:40:20 PDT 2020
Author: Florian Hahn
Date: 2020-10-02T13:38:53+01:00
New Revision: bb448a248371b48dbca8d647b7aaf9393154cf3d
URL: https://github.com/llvm/llvm-project/commit/bb448a248371b48dbca8d647b7aaf9393154cf3d
DIFF: https://github.com/llvm/llvm-project/commit/bb448a248371b48dbca8d647b7aaf9393154cf3d.diff
LOG: [SLP] Add test where reduction result is used in PHI.
Test case for PR47670.
Added:
Modified:
llvm/test/Transforms/SLPVectorizer/X86/horizontal.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/SLPVectorizer/X86/horizontal.ll b/llvm/test/Transforms/SLPVectorizer/X86/horizontal.ll
index fb7a0b5bedc7..703ebbf9dd73 100644
--- a/llvm/test/Transforms/SLPVectorizer/X86/horizontal.ll
+++ b/llvm/test/Transforms/SLPVectorizer/X86/horizontal.ll
@@ -1626,4 +1626,65 @@ normal:
ret void
}
+; Test case from PR47670. Reduction result is used as incoming value in phi.
+define i32 @reduction_result_used_in_phi(i32* nocapture readonly %data, i1 zeroext %b) {
+; CHECK-LABEL: @reduction_result_used_in_phi(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br i1 [[B:%.*]], label [[BB:%.*]], label [[EXIT:%.*]]
+; CHECK: bb:
+; CHECK-NEXT: [[L_0:%.*]] = load i32, i32* [[DATA:%.*]], align 4
+; CHECK-NEXT: [[IDX_1:%.*]] = getelementptr inbounds i32, i32* [[DATA]], i64 1
+; CHECK-NEXT: [[L_1:%.*]] = load i32, i32* [[IDX_1]], align 4
+; CHECK-NEXT: [[ADD_1:%.*]] = add i32 [[L_1]], [[L_0]]
+; CHECK-NEXT: [[IDX_2:%.*]] = getelementptr inbounds i32, i32* [[DATA]], i64 2
+; CHECK-NEXT: [[L_2:%.*]] = load i32, i32* [[IDX_2]], align 4
+; CHECK-NEXT: [[ADD_2:%.*]] = add i32 [[L_2]], [[ADD_1]]
+; CHECK-NEXT: [[IDX_3:%.*]] = getelementptr inbounds i32, i32* [[DATA]], i64 3
+; CHECK-NEXT: [[L_3:%.*]] = load i32, i32* [[IDX_3]], align 4
+; CHECK-NEXT: [[ADD_3:%.*]] = add i32 [[L_3]], [[ADD_2]]
+; CHECK-NEXT: br label [[EXIT]]
+; CHECK: exit:
+; CHECK-NEXT: [[SUM_1:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[ADD_3]], [[BB]] ]
+; CHECK-NEXT: ret i32 [[SUM_1]]
+;
+; STORE-LABEL: @reduction_result_used_in_phi(
+; STORE-NEXT: entry:
+; STORE-NEXT: br i1 [[B:%.*]], label [[BB:%.*]], label [[EXIT:%.*]]
+; STORE: bb:
+; STORE-NEXT: [[L_0:%.*]] = load i32, i32* [[DATA:%.*]], align 4
+; STORE-NEXT: [[IDX_1:%.*]] = getelementptr inbounds i32, i32* [[DATA]], i64 1
+; STORE-NEXT: [[L_1:%.*]] = load i32, i32* [[IDX_1]], align 4
+; STORE-NEXT: [[ADD_1:%.*]] = add i32 [[L_1]], [[L_0]]
+; STORE-NEXT: [[IDX_2:%.*]] = getelementptr inbounds i32, i32* [[DATA]], i64 2
+; STORE-NEXT: [[L_2:%.*]] = load i32, i32* [[IDX_2]], align 4
+; STORE-NEXT: [[ADD_2:%.*]] = add i32 [[L_2]], [[ADD_1]]
+; STORE-NEXT: [[IDX_3:%.*]] = getelementptr inbounds i32, i32* [[DATA]], i64 3
+; STORE-NEXT: [[L_3:%.*]] = load i32, i32* [[IDX_3]], align 4
+; STORE-NEXT: [[ADD_3:%.*]] = add i32 [[L_3]], [[ADD_2]]
+; STORE-NEXT: br label [[EXIT]]
+; STORE: exit:
+; STORE-NEXT: [[SUM_1:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[ADD_3]], [[BB]] ]
+; STORE-NEXT: ret i32 [[SUM_1]]
+;
+entry:
+ br i1 %b, label %bb, label %exit
+
+bb:
+ %l.0 = load i32, i32* %data, align 4
+ %idx.1 = getelementptr inbounds i32, i32* %data, i64 1
+ %l.1 = load i32, i32* %idx.1, align 4
+ %add.1 = add i32 %l.1, %l.0
+ %idx.2 = getelementptr inbounds i32, i32* %data, i64 2
+ %l.2 = load i32, i32* %idx.2, align 4
+ %add.2 = add i32 %l.2, %add.1
+ %idx.3 = getelementptr inbounds i32, i32* %data, i64 3
+ %l.3 = load i32, i32* %idx.3, align 4
+ %add.3 = add i32 %l.3, %add.2
+ br label %exit
+
+exit:
+ %sum.1 = phi i32 [ 0, %entry ], [ %add.3, %bb]
+ ret i32 %sum.1
+}
+
declare i32 @__gxx_personality_v0(...)
More information about the llvm-commits
mailing list