summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@intel.com>2018-10-30 18:48:42 +0000
committerCraig Topper <craig.topper@intel.com>2018-10-30 18:48:42 +0000
commit6958b5ffa9ed00d499e81f815a02eaff02cc9614 (patch)
tree043b5e13e0a7517ecbb89558a112e5dc611c5758
parent4b0c66deb368bd2f953035dff847a49ea404a4b9 (diff)
downloadbcm5719-llvm-6958b5ffa9ed00d499e81f815a02eaff02cc9614.tar.gz
bcm5719-llvm-6958b5ffa9ed00d499e81f815a02eaff02cc9614.zip
[X86] In lowerVectorShuffleAsBroadcast, make peeking through CONCAT_VECTORS work correctly if we already walked through a bitcast that changed the element size.
The CONCAT_VECTORS case was using the original mask element count to determine how to adjust the broadcast index. But if we looked through a bitcast the original mask size doesn't tell us anything about the concat_vectors. This patch switchs to using the concat_vectors input element count directly instead. Differential Revision: https://reviews.llvm.org/D53823 llvm-svn: 345626
-rw-r--r--llvm/lib/Target/X86/X86ISelLowering.cpp3
-rw-r--r--llvm/test/CodeGen/X86/vector-shuffle-256-v8.ll29
2 files changed, 31 insertions, 1 deletions
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index da5340a050b..9acae2cab22 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -11238,7 +11238,8 @@ static SDValue lowerVectorShuffleAsBroadcast(const SDLoc &DL, MVT VT,
continue;
}
case ISD::CONCAT_VECTORS: {
- int OperandSize = Mask.size() / V.getNumOperands();
+ int OperandSize =
+ V.getOperand(0).getSimpleValueType().getVectorNumElements();
V = V.getOperand(BroadcastIdx / OperandSize);
BroadcastIdx %= OperandSize;
continue;
diff --git a/llvm/test/CodeGen/X86/vector-shuffle-256-v8.ll b/llvm/test/CodeGen/X86/vector-shuffle-256-v8.ll
index 74c477300d6..addf2d2563f 100644
--- a/llvm/test/CodeGen/X86/vector-shuffle-256-v8.ll
+++ b/llvm/test/CodeGen/X86/vector-shuffle-256-v8.ll
@@ -2848,3 +2848,32 @@ entry:
%add = add <8 x i32> %shuffle, %shuffle1
ret <8 x i32> %add
}
+
+; This test used to crash due to bad handling of concat_vectors after a bitcast
+; in lowerVectorShuffleAsBroadcast.
+define <8 x float> @broadcast_concat_crash(<4 x float> %x, <4 x float> %y, float %z) {
+; AVX1-LABEL: broadcast_concat_crash:
+; AVX1: # %bb.0: # %entry
+; AVX1-NEXT: vpermilps {{.*#+}} xmm0 = xmm1[3,3,1,1]
+; AVX1-NEXT: vinsertps {{.*#+}} xmm0 = xmm0[0],xmm2[0],xmm0[2,3]
+; AVX1-NEXT: vinsertf128 $1, %xmm0, %ymm0, %ymm0
+; AVX1-NEXT: retq
+;
+; AVX2OR512VL-LABEL: broadcast_concat_crash:
+; AVX2OR512VL: # %bb.0: # %entry
+; AVX2OR512VL-NEXT: vinsertf128 $1, %xmm1, %ymm0, %ymm0
+; AVX2OR512VL-NEXT: vpermpd {{.*#+}} ymm0 = ymm0[3,1,2,3]
+; AVX2OR512VL-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[1,1,3,3]
+; AVX2OR512VL-NEXT: vinsertps {{.*#+}} xmm0 = xmm0[0],xmm2[0],xmm0[2,3]
+; AVX2OR512VL-NEXT: vinsertf128 $1, %xmm0, %ymm0, %ymm0
+; AVX2OR512VL-NEXT: retq
+entry:
+ %tmp = shufflevector <4 x float> %x, <4 x float> %y, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
+ %bc = bitcast <8 x float> %tmp to <4 x i64>
+ %tmp1 = extractelement <4 x i64> %bc, i32 3
+ %tmp2 = bitcast i64 %tmp1 to <2 x float>
+ %tmp4 = extractelement <2 x float> %tmp2, i32 1
+ %tmp5 = insertelement <8 x float> undef, float %tmp4, i32 4
+ %tmp6 = insertelement <8 x float> %tmp5, float %z, i32 5
+ ret <8 x float> %tmp6
+}
OpenPOWER on IntegriCloud