[PATCH] D51639: [LV] Fix PR38786 - consider first order recurrence phis non-uniform
Orivej Desh via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 4 08:57:27 PDT 2018
orivej created this revision.
orivej added reviewers: Ayal, anna, mssimpso, hans, silviu.baranga.
Herald added subscribers: llvm-commits, rkruppe.
Patch by Ayal Zaks
Repository:
rL LLVM
https://reviews.llvm.org/D51639
Files:
lib/Transforms/Vectorize/LoopVectorize.cpp
test/Transforms/LoopVectorize/X86/uniform-phi.ll
Index: test/Transforms/LoopVectorize/X86/uniform-phi.ll
===================================================================
--- test/Transforms/LoopVectorize/X86/uniform-phi.ll
+++ test/Transforms/LoopVectorize/X86/uniform-phi.ll
@@ -75,3 +75,26 @@
ret i64 %retval
}
+; CHECK-LABEL: PR38786
+; Check that phis (%phi32 and %phi64) are not uniform.
+; CHECK-NOT: LV: Found uniform instruction: %phi
+
+define void @PR38786(double* %y, double* %x, i64 %n) {
+entry:
+ br label %for.body
+
+for.body:
+ %phi32 = phi i32 [ 0, %entry ], [ %i32next, %for.body ]
+ %phi64 = phi i64 [ 0, %entry ], [ %i32as64, %for.body ]
+ %i32next = add i32 %phi32, 1
+ %i32as64 = zext i32 %i32next to i64
+ %xip = getelementptr inbounds double, double* %x, i64 %i32as64
+ %yip = getelementptr inbounds double, double* %y, i64 %phi64
+ %xi = load double, double* %xip, align 8
+ store double %xi, double* %yip, align 8
+ %cmp = icmp slt i64 %i32as64, %n
+ br i1 %cmp, label %for.body, label %for.end
+
+for.end:
+ ret void
+}
Index: lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- lib/Transforms/Vectorize/LoopVectorize.cpp
+++ lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -4529,6 +4529,11 @@
// isOutOfScope operands cannot be uniform instructions.
if (isOutOfScope(OV))
continue;
+ // First order recurrence Phi's should typically be considered
+ // non-uniform.
+ auto *OP = dyn_cast<PHINode>(OV);
+ if (OP && Legal->isFirstOrderRecurrence(OP))
+ continue;
// If all the users of the operand are uniform, then add the
// operand into the uniform worklist.
auto *OI = cast<Instruction>(OV);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51639.163839.patch
Type: text/x-patch
Size: 1728 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180904/fac9059d/attachment.bin>
More information about the llvm-commits
mailing list