[PATCH] D81634: Remove assert from ShuffleVectorInst
Sam Parker via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 11 07:09:24 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3d5f7c853173: [IR] Remove assert from ShuffleVectorInst (authored by samparker).
Changed prior to commit:
https://reviews.llvm.org/D81634?vs=270112&id=270130#toc
Repository:
rG LLVM Github Monorepo
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,14 @@
+; RUN: opt -codegenprepare -S %s | FileCheck %s
+
+target triple = "x86_64-unknown-linux-gnu"
+
+; CHECK-LABEL: shuffle_one_source
+
+define <2 x i8> @shuffle_one_source(i32 %x) {
+ %Shuf = shufflevector <2 x i8> zeroinitializer, <2 x i8> zeroinitializer, <2 x i32> undef
+ %Cmp = icmp slt i32 480483, %x
+ %B = mul <2 x i8> %Shuf, %Shuf
+ %S = select i1 %Cmp, <2 x i8> %B, <2 x i8> zeroinitializer
+ ret <2 x i8> %Shuf
+}
+
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.270130.patch
Type: text/x-patch
Size: 2192 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200611/1ffb4e87/attachment.bin>
More information about the llvm-commits
mailing list