[PATCH] D126895: [SLP] Phi inputs that come from an unreachable block should be undef.
Vasileios Porpodas via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 2 12:46:05 PDT 2022
vporpo updated this revision to Diff 433848.
vporpo added a comment.
If the input is undef keep it, else create a poison value.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126895/new/
https://reviews.llvm.org/D126895
Files:
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/test/Transforms/SLPVectorizer/X86/malformed_phis.ll
llvm/test/Transforms/SLPVectorizer/X86/phi-unreachable-input-block.ll
Index: llvm/test/Transforms/SLPVectorizer/X86/phi-unreachable-input-block.ll
===================================================================
--- llvm/test/Transforms/SLPVectorizer/X86/phi-unreachable-input-block.ll
+++ llvm/test/Transforms/SLPVectorizer/X86/phi-unreachable-input-block.ll
@@ -15,7 +15,7 @@
; CHECK: bb2:
; CHECK-NEXT: br label [[BB3]]
; CHECK: bb3:
-; CHECK-NEXT: [[TMP2:%.*]] = phi <2 x i8> [ [[TMP1]], [[BB1:%.*]] ], [ poison, [[BB2:%.*]] ]
+; CHECK-NEXT: [[TMP2:%.*]] = phi <2 x i8> [ [[TMP1]], [[BB1:%.*]] ], [ <i8 undef, i8 0>, [[BB2:%.*]] ]
; CHECK-NEXT: [[TMP3:%.*]] = zext <2 x i8> [[TMP2]] to <2 x i64>
; CHECK-NEXT: [[GEP0:%.*]] = getelementptr i64, i64* [[PTR:%.*]], i64 0
; CHECK-NEXT: [[TMP4:%.*]] = bitcast i64* [[GEP0]] to <2 x i64>*
Index: llvm/test/Transforms/SLPVectorizer/X86/malformed_phis.ll
===================================================================
--- llvm/test/Transforms/SLPVectorizer/X86/malformed_phis.ll
+++ llvm/test/Transforms/SLPVectorizer/X86/malformed_phis.ll
@@ -116,7 +116,7 @@
; CHECK: bb2:
; CHECK-NEXT: br label [[BB3]]
; CHECK: bb3:
-; CHECK-NEXT: [[TMP0:%.*]] = phi <2 x i32> [ undef, [[BB1]] ], [ poison, [[BB2:%.*]] ]
+; CHECK-NEXT: [[TMP0:%.*]] = phi <2 x i32> [ undef, [[BB1]] ], [ undef, [[BB2:%.*]] ]
; CHECK-NEXT: [[SHUFFLE:%.*]] = shufflevector <2 x i32> [[TMP0]], <2 x i32> poison, <8 x i32> <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 1>
; CHECK-NEXT: [[TMP1:%.*]] = extractelement <8 x i32> [[SHUFFLE]], i32 0
; CHECK-NEXT: [[TMP2:%.*]] = insertelement <16 x i32> poison, i32 [[TMP1]], i32 0
Index: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -4750,7 +4750,8 @@
// Keeps the reordered operands to avoid code duplication.
SmallVector<ValueList, 2> OperandsVec;
for (unsigned I = 0, E = PH->getNumIncomingValues(); I < E; ++I) {
- if (!DT->isReachableFromEntry(PH->getIncomingBlock(I))) {
+ if (!DT->isReachableFromEntry(PH->getIncomingBlock(I)) &&
+ !isa<UndefValue>(PH->getIncomingValue(I))) {
ValueList Operands(VL.size(), PoisonValue::get(PH->getType()));
TE->setOperand(I, Operands);
OperandsVec.push_back(Operands);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126895.433848.patch
Type: text/x-patch
Size: 2442 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220602/87d1a8d2/attachment.bin>
More information about the llvm-commits
mailing list