[PATCH] D81634: Remove assert from ShuffleVectorInst
Sam Parker via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 11 06:01:39 PDT 2020
samparker updated this revision to Diff 270112.
samparker added a comment.
- Changed return value and added comment.
- Added a few internal UndefValue where possible.
- Moved test.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D81634/new/
https://reviews.llvm.org/D81634
Files:
llvm/lib/IR/Instructions.cpp
llvm/test/Transforms/CodeGenPrepare/X86/cgp_shuffle_crash.ll
Index: llvm/test/Transforms/CodeGenPrepare/X86/cgp_shuffle_crash.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/CodeGenPrepare/X86/cgp_shuffle_crash.ll
@@ -0,0 +1,23 @@
+; RUN: opt -codegenprepare -S %s | FileCheck %s
+
+target triple = "x86_64-unknown-linux-gnu"
+
+; CHECK-LABEL: shuffle_one_source
+
+define void @shuffle_one_source() {
+BB:
+ %Shuff7 = shufflevector <2 x i8> zeroinitializer, <2 x i8> zeroinitializer, <2 x i32> undef
+ br label %CF
+
+CF: ; preds = %CF, %BB
+ %Cmp82 = icmp slt i32 480483, undef
+ br i1 undef, label %CF, label %CF242
+
+CF242: ; preds = %CF
+ %B109 = mul <2 x i8> undef, %Shuff7
+ br label %CF245
+
+CF245: ; preds = %CF245, %CF242
+ %Sl187 = select i1 %Cmp82, <2 x i8> %B109, <2 x i8> undef
+ br label %CF245
+}
Index: llvm/lib/IR/Instructions.cpp
===================================================================
--- llvm/lib/IR/Instructions.cpp
+++ llvm/lib/IR/Instructions.cpp
@@ -2053,8 +2053,8 @@
if (UsesLHS && UsesRHS)
return false;
}
- assert((UsesLHS ^ UsesRHS) && "Should have selected from exactly 1 source");
- return true;
+ // Allow for degenerate case: completely undef mask means neither source is used.
+ return UsesLHS || UsesRHS;
}
bool ShuffleVectorInst::isSingleSourceMask(ArrayRef<int> Mask) {
@@ -2182,6 +2182,8 @@
}
bool ShuffleVectorInst::isIdentityWithPadding() const {
+ if (isa<UndefValue>(Op<2>()))
+ return false;
int NumOpElts = cast<VectorType>(Op<0>()->getType())->getNumElements();
int NumMaskElts = cast<VectorType>(getType())->getNumElements();
if (NumMaskElts <= NumOpElts)
@@ -2201,6 +2203,8 @@
}
bool ShuffleVectorInst::isIdentityWithExtract() const {
+ if (isa<UndefValue>(Op<2>()))
+ return false;
int NumOpElts = cast<VectorType>(Op<0>()->getType())->getNumElements();
int NumMaskElts = getType()->getNumElements();
if (NumMaskElts >= NumOpElts)
@@ -2211,7 +2215,8 @@
bool ShuffleVectorInst::isConcat() const {
// Vector concatenation is differentiated from identity with padding.
- if (isa<UndefValue>(Op<0>()) || isa<UndefValue>(Op<1>()))
+ if (isa<UndefValue>(Op<0>()) || isa<UndefValue>(Op<1>()) ||
+ isa<UndefValue>(Op<2>()))
return false;
int NumOpElts = cast<VectorType>(Op<0>()->getType())->getNumElements();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81634.270112.patch
Type: text/x-patch
Size: 2485 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200611/7b68328e/attachment.bin>
More information about the llvm-commits
mailing list