llvm.org GIT mirror llvm / 527fa8c
[X86] Fix assertion failure caused by a wrong folding of vector shifts by immediate count. This fixes a regression intruced by r198113. Revision r198113 introduced an algorithm that tries to fold a vector shift by immediate count into a build_vector if the input vector is a known vector of constants. However the algorithm only worked under the assumption that the input vector type and the shift type are exactly the same. This patch disables the folding of vector shift by immediate count if the input vector type and the shift value type are not the same. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199213 91177308-0d34-0410-b5e6-96231b3b80d8 Andrea Di Biagio 6 years ago
2 changed file(s) with 39 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
1111711117 && "Unknown target vector shift-by-constant node");
1111811118
1111911119 // Fold this packed vector shift into a build vector if SrcOp is a
11120 // vector of ConstantSDNodes or UNDEFs.
11121 if (ISD::isBuildVectorOfConstantSDNodes(SrcOp.getNode())) {
11120 // vector of Constants or UNDEFs, and SrcOp valuetype is the same as VT.
11121 if (VT == SrcOp.getSimpleValueType() &&
11122 ISD::isBuildVectorOfConstantSDNodes(SrcOp.getNode())) {
1112211123 SmallVector Elts;
1112311124 unsigned NumElts = SrcOp->getNumOperands();
1112411125 ConstantSDNode *ND;
0 ; RUN: llc < %s -mcpu=corei7 -march=x86-64 -mattr=+sse2 | FileCheck %s
1
2 ; This test makes sure that the compiler does not crash with an
3 ; assertion failure when trying to fold a vector shift left
4 ; by immediate count if the type of the input vector is different
5 ; to the result type.
6 ;
7 ; This happens for example when lowering a shift left of a MVT::v16i8 vector.
8 ; This is custom lowered into the following sequence:
9 ; count << 5
10 ; A = VSHLI(MVT::v8i16, r & (char16)15, 4)
11 ; B = BITCAST MVT::v16i8, A
12 ; VSELECT(r, B, count);
13 ; count += count
14 ; C = VSHLI(MVT::v8i16, r & (char16)63, 2)
15 ; D = BITCAST MVT::v16i8, C
16 ; r = VSELECT(r, C, count);
17 ; count += count
18 ; VSELECT(r, r+r, count);
19 ; count = count << 5;
20 ;
21 ; Where 'r' is a vector of type MVT::v16i8, and
22 ; 'count' is the vector shift count.
23
24 define <16 x i8> @do_not_crash(i8*, i32*, i64*, i32, i64, i8) {
25 entry:
26 store i8 %5, i8* %0
27 %L5 = load i8* %0
28 %I8 = insertelement <16 x i8> , i8 %L5, i32 7
29 %B51 = shl <16 x i8> , %I8
30 ret <16 x i8> %B51
31 }
32
33 ; CHECK-LABEL: do_not_crash
34 ; CHECK: ret
35