[llvm] r228979 - X86: Don't crash if we can't decode the pshufb mask
David Majnemer
david.majnemer at gmail.com
Thu Feb 12 15:26:26 PST 2015
Author: majnemer
Date: Thu Feb 12 17:26:26 2015
New Revision: 228979
URL: http://llvm.org/viewvc/llvm-project?rev=228979&view=rev
Log:
X86: Don't crash if we can't decode the pshufb mask
Constant pool entries are uniqued by their contents regardless of their
type. This means that a pshufb can have a shuffle mask which isn't a
simple array of bytes.
The code path which attempts to decode the mask didn't check for
failure, causing PR22559.
Modified:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
llvm/trunk/test/CodeGen/X86/pshufb-mask-comments.ll
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=228979&r1=228978&r2=228979&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Thu Feb 12 17:26:26 2015
@@ -5480,6 +5480,8 @@ static bool getTargetShuffleMask(SDNode
if (auto *C = dyn_cast<Constant>(MaskCP->getConstVal())) {
DecodePSHUFBMask(C, Mask);
+ if (Mask.empty())
+ return false;
break;
}
Modified: llvm/trunk/test/CodeGen/X86/pshufb-mask-comments.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/pshufb-mask-comments.ll?rev=228979&r1=228978&r2=228979&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/pshufb-mask-comments.ll (original)
+++ llvm/trunk/test/CodeGen/X86/pshufb-mask-comments.ll Thu Feb 12 17:26:26 2015
@@ -37,4 +37,16 @@ define <16 x i8> @test4(<2 x i64>* %V) {
ret <16 x i8> %1
}
+define <16 x i8> @test5() {
+; CHECK-LABEL: test5
+; CHECK: pshufb {{.*}}
+ store <2 x i64> <i64 1, i64 0>, <2 x i64>* undef, align 16
+ %l = load <2 x i64>* undef, align 16
+ %shuffle = shufflevector <2 x i64> %l, <2 x i64> undef, <2 x i32> zeroinitializer
+ store <2 x i64> %shuffle, <2 x i64>* undef, align 16
+ %1 = load <16 x i8>* undef, align 16
+ %2 = call <16 x i8> @llvm.x86.ssse3.pshuf.b.128(<16 x i8> undef, <16 x i8> %1)
+ ret <16 x i8> %2
+}
+
declare <16 x i8> @llvm.x86.ssse3.pshuf.b.128(<16 x i8>, <16 x i8>) nounwind readnone
More information about the llvm-commits
mailing list