llvm.org GIT mirror llvm / 9daabae
Prevent X86ISelLowering from merging volatile loads Change isConsecutiveLoads to check that loads are non-volatile as this is a requirement for any load merges. Propagate change to two callers. Reviewers: RKSimon Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D18546 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265013 91177308-0d34-0410-b5e6-96231b3b80d8 Nirav Dave 4 years ago
4 changed file(s) with 22 addition(s) and 25 deletion(s). Raw diff Collapse all Expand all
12831283 /// vector op and fill the end of the resulting vector with UNDEFS.
12841284 SDValue UnrollVectorOp(SDNode *N, unsigned ResNE = 0);
12851285
1286 /// Return true if LD is loading 'Bytes' bytes from a location that is 'Dist'
1287 /// units away from the location that the 'Base' load is loading from.
1288 bool isConsecutiveLoad(LoadSDNode *LD, LoadSDNode *Base,
1289 unsigned Bytes, int Dist) const;
1286 /// Return true if loads are next to each other and can be
1287 /// merged. Check that both are nonvolatile and if LD is loading
1288 /// 'Bytes' bytes from a location that is 'Dist' units away from the
1289 /// location that the 'Base' load is loading from.
1290 bool areNonVolatileConsecutiveLoads(LoadSDNode *LD, LoadSDNode *Base,
1291 unsigned Bytes, int Dist) const;
12901292
12911293 /// Infer alignment of a load / store address. Return 0 if
12921294 /// it cannot be inferred.
72507250 LD1->getAddressSpace() != LD2->getAddressSpace())
72517251 return SDValue();
72527252 EVT LD1VT = LD1->getValueType(0);
7253
7254 if (ISD::isNON_EXTLoad(LD2) &&
7255 LD2->hasOneUse() &&
7256 // If both are volatile this would reduce the number of volatile loads.
7257 // If one is volatile it might be ok, but play conservative and bail out.
7258 !LD1->isVolatile() &&
7259 !LD2->isVolatile() &&
7260 DAG.isConsecutiveLoad(LD2, LD1, LD1VT.getSizeInBits()/8, 1)) {
7253 unsigned LD1Bytes = LD1VT.getSizeInBits() / 8;
7254 if (ISD::isNON_EXTLoad(LD2) && LD2->hasOneUse() &&
7255 DAG.areNonVolatileConsecutiveLoads(LD2, LD1, LD1Bytes, 1)) {
72617256 unsigned Align = LD1->getAlignment();
72627257 unsigned NewAlign = DAG.getDataLayout().getABITypeAlignment(
72637258 VT.getTypeForEVT(*DAG.getContext()));
69586958 EVT::getVectorVT(*getContext(), EltVT, ResNE), Scalars);
69596959 }
69606960
6961
6962 /// isConsecutiveLoad - Return true if LD is loading 'Bytes' bytes from a
6963 /// location that is 'Dist' units away from the location that the 'Base' load
6964 /// is loading from.
6965 bool SelectionDAG::isConsecutiveLoad(LoadSDNode *LD, LoadSDNode *Base,
6966 unsigned Bytes, int Dist) const {
6961 bool SelectionDAG::areNonVolatileConsecutiveLoads(LoadSDNode *LD,
6962 LoadSDNode *Base,
6963 unsigned Bytes,
6964 int Dist) const {
6965 if (LD->isVolatile() || Base->isVolatile())
6966 return false;
69676967 if (LD->getChain() != Base->getChain())
69686968 return false;
69696969 EVT VT = LD->getValueType(0);
57355735 if (LoadMask[i]) {
57365736 SDValue Elt = peekThroughBitcasts(Elts[i]);
57375737 LoadSDNode *LD = cast(Elt);
5738 if (!DAG.isConsecutiveLoad(LD, LDBase,
5739 Elt.getValueType().getStoreSizeInBits() / 8,
5740 i - FirstLoadedElt)) {
5738 if (!DAG.areNonVolatileConsecutiveLoads(
5739 LD, LDBase, Elt.getValueType().getStoreSizeInBits() / 8,
5740 i - FirstLoadedElt)) {
57415741 IsConsecutiveLoad = false;
57425742 IsConsecutiveLoadWithZeros = false;
57435743 break;
57485748 }
57495749
57505750 auto CreateLoad = [&DAG, &DL](EVT VT, LoadSDNode *LDBase) {
5751 SDValue NewLd = DAG.getLoad(VT, DL, LDBase->getChain(),
5752 LDBase->getBasePtr(), LDBase->getPointerInfo(),
5753 LDBase->isVolatile(), LDBase->isNonTemporal(),
5754 LDBase->isInvariant(), LDBase->getAlignment());
5751 SDValue NewLd = DAG.getLoad(
5752 VT, DL, LDBase->getChain(), LDBase->getBasePtr(),
5753 LDBase->getPointerInfo(), false /*LDBase->isVolatile()*/,
5754 LDBase->isNonTemporal(), LDBase->isInvariant(), LDBase->getAlignment());
57555755
57565756 if (LDBase->hasAnyUseOfValue(1)) {
57575757 SDValue NewChain =