llvm.org GIT mirror llvm / 0787274
Fix PR14161 - Check index being extracted to be constant 0 before simplfiying. Otherwise, retain the original sequence. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166504 91177308-0d34-0410-b5e6-96231b3b80d8 Michael Liao 7 years ago
2 changed file(s) with 42 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
66296629 .getOperand(0).getValueType().getSizeInBits() == SignificantBits) {
66306630 // (bitcast (sclr2vec (ext_vec_elt x))) -> (bitcast x)
66316631 SDValue V = V1.getOperand(0).getOperand(0).getOperand(0);
6632 ConstantSDNode *CIdx =
6633 dyn_cast(V1.getOperand(0).getOperand(0).getOperand(1));
66326634 // If it's foldable, i.e. normal load with single use, we will let code
66336635 // selection to fold it. Otherwise, we will short the conversion sequence.
6634 if (!ISD::isNormalLoad(V.getNode()) || !V.hasOneUse())
6636 if (CIdx && CIdx->getZExtValue() == 0 &&
6637 (!ISD::isNormalLoad(V.getNode()) || !V.hasOneUse()))
66356638 V1 = DAG.getNode(ISD::BITCAST, DL, V1.getValueType(), V);
66366639 }
66376640
0 ; RUN: llc < %s -mtriple=x86_64-linux-pc -mcpu=corei7 | FileCheck %s
1
2 declare <4 x i32> @llvm.x86.sse41.pminud(<4 x i32>, <4 x i32>)
3
4 define <2 x i16> @good(<4 x i32>*, <4 x i8>*) {
5 entry:
6 %2 = load <4 x i32>* %0, align 16
7 %3 = call <4 x i32> @llvm.x86.sse41.pminud(<4 x i32> %2, <4 x i32> )
8 %4 = extractelement <4 x i32> %3, i32 0
9 %5 = extractelement <4 x i32> %3, i32 1
10 %6 = extractelement <4 x i32> %3, i32 2
11 %7 = extractelement <4 x i32> %3, i32 3
12 %8 = bitcast i32 %4 to <2 x i16>
13 %9 = bitcast i32 %5 to <2 x i16>
14 ret <2 x i16> %8
15 ; CHECK: good
16 ; CHECK: pminud
17 ; CHECK-NEXT: pmovzxwq
18 ; CHECK: ret
19 }
20
21 define <2 x i16> @bad(<4 x i32>*, <4 x i8>*) {
22 entry:
23 %2 = load <4 x i32>* %0, align 16
24 %3 = call <4 x i32> @llvm.x86.sse41.pminud(<4 x i32> %2, <4 x i32> )
25 %4 = extractelement <4 x i32> %3, i32 0
26 %5 = extractelement <4 x i32> %3, i32 1
27 %6 = extractelement <4 x i32> %3, i32 2
28 %7 = extractelement <4 x i32> %3, i32 3
29 %8 = bitcast i32 %4 to <2 x i16>
30 %9 = bitcast i32 %5 to <2 x i16>
31 ret <2 x i16> %9
32 ; CHECK: bad
33 ; CHECK: pminud
34 ; CHECK: pextrd
35 ; CHECK: pmovzxwq
36 ; CHECK: ret
37 }