llvm.org GIT mirror llvm / d6e2560
Make sure DAGCombiner doesn't introduce multiple loads from the same memory location. PR10747, part 2. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147283 91177308-0d34-0410-b5e6-96231b3b80d8 Eli Friedman 8 years ago
3 changed file(s) with 44 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
69046904 EVT LVT = ExtVT;
69056905
69066906 if (InVec.getOpcode() == ISD::BITCAST) {
6907 // Don't duplicate a load with other uses.
6908 if (!InVec.hasOneUse())
6909 return SDValue();
6910
69076911 EVT BCVT = InVec.getOperand(0).getValueType();
69086912 if (!BCVT.isVector() || ExtVT.bitsGT(BCVT.getVectorElementType()))
69096913 return SDValue();
69216925 } else if (InVec.getOpcode() == ISD::SCALAR_TO_VECTOR &&
69226926 InVec.getOperand(0).getValueType() == ExtVT &&
69236927 ISD::isNormalLoad(InVec.getOperand(0).getNode())) {
6928 // Don't duplicate a load with other uses.
6929 if (!InVec.hasOneUse())
6930 return SDValue();
6931
69246932 LN0 = cast(InVec.getOperand(0));
69256933 } else if ((SVN = dyn_cast(InVec))) {
69266934 // (vextract (vector_shuffle (load $addr), v2, <1, u, u, u>), 1)
69276935 // =>
69286936 // (load $addr+1*size)
69296937
6938 // Don't duplicate a load with other uses.
6939 if (!InVec.hasOneUse())
6940 return SDValue();
6941
69306942 // If the bit convert changed the number of elements, it is unsafe
69316943 // to examine the mask.
69326944 if (BCNumEltsChanged)
69376949 int Idx = (Elt > (int)NumElems) ? -1 : SVN->getMaskElt(Elt);
69386950 InVec = (Idx < (int)NumElems) ? InVec.getOperand(0) : InVec.getOperand(1);
69396951
6940 if (InVec.getOpcode() == ISD::BITCAST)
6952 if (InVec.getOpcode() == ISD::BITCAST) {
6953 // Don't duplicate a load with other uses.
6954 if (!InVec.hasOneUse())
6955 return SDValue();
6956
69416957 InVec = InVec.getOperand(0);
6958 }
69426959 if (ISD::isNormalLoad(InVec.getNode())) {
69436960 LN0 = cast(InVec);
69446961 Elt = (Idx < (int)NumElems) ? Idx : Idx - (int)NumElems;
69456962 }
69466963 }
69476964
6965 // Make sure we found a non-volatile load and the extractelement is
6966 // the only use.
69486967 if (!LN0 || !LN0->hasNUsesOfValue(1,0) || LN0->isVolatile())
69496968 return SDValue();
69506969
69817000 // The replacement we need to do here is a little tricky: we need to
69827001 // replace an extractelement of a load with a load.
69837002 // Use ReplaceAllUsesOfValuesWith to do the replacement.
7003 // Note that this replacement assumes that the extractvalue is the only
7004 // use of the load; that's okay because we don't want to perform this
7005 // transformation in other cases anyway.
69847006 SDValue Load = DAG.getLoad(LVT, N->getDebugLoc(), LN0->getChain(), NewPtr,
69857007 LN0->getPointerInfo().getWithOffset(PtrOff),
69867008 LN0->isVolatile(), LN0->isNonTemporal(),
77
88 ; CHECK: movw r1, :lower16:{{.*}}
99 ; CHECK: movt r1, :upper16:{{.*}}
10 ; CHECK: vldmia r1, {[[short0:s[0-9]+]], [[short1:s[0-9]+]], [[short2:s[0-9]+]], [[short3:s[0-9]+]]}
11 ; CHECK: vsqrt.f32 {{s[0-9]+}}, [[short3]]
12 ; CHECK: vsqrt.f32 {{s[0-9]+}}, [[short2]]
13 ; CHECK: vsqrt.f32 {{s[0-9]+}}, [[short1]]
14 ; CHECK: vsqrt.f32 {{s[0-9]+}}, [[short0]]
10 ; CHECK: vldmia r1
11 ; CHECK: vsqrt.f32 {{s[0-9]+}}, {{s[0-9]+}}
12 ; CHECK: vsqrt.f32 {{s[0-9]+}}, {{s[0-9]+}}
13 ; CHECK: vsqrt.f32 {{s[0-9]+}}, {{s[0-9]+}}
14 ; CHECK: vsqrt.f32 {{s[0-9]+}}, {{s[0-9]+}}
1515 ; CHECK: vstmia {{.*}}
1616
1717 L.entry:
0 ; RUN: llc -march=x86-64 -mattr=-sse42,+sse41 < %s | FileCheck %s
1 ; Make sure we don't load from the location pointed to by %p
2 ; twice: it has non-obvious performance implications, and
3 ; the relevant transformation doesn't know how to update
4 ; the chains correctly.
5 ; PR10747
6
7 ; CHECK: test:
8 ; CHECK: pextrd $2, %xmm
9 define <4 x i32> @test(<4 x i32>* %p) {
10 %v = load <4 x i32>* %p
11 %e = extractelement <4 x i32> %v, i32 2
12 %cmp = icmp eq i32 %e, 3
13 %sel = select i1 %cmp, <4 x i32> %v, <4 x i32> zeroinitializer
14 ret <4 x i32> %sel
15 }