[PATCH] D40667: [DAGCombine] Simplify ISD::AND handling in ReduceLoadWidth
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 1 11:34:26 PST 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319573: [DAGCombine] Simplify ISD::AND handling in ReduceLoadWidth (authored by efriedma).
Changed prior to commit:
https://reviews.llvm.org/D40667?vs=124988&id=125186#toc
Repository:
rL LLVM
https://reviews.llvm.org/D40667
Files:
llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Index: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -8019,29 +8019,14 @@
ExtVT = EVT::getIntegerVT(*DAG.getContext(),
VT.getSizeInBits() - ShiftAmt);
} else if (Opc == ISD::AND) {
- bool HasAnyExt = N0.getOpcode() == ISD::ANY_EXTEND;
- LoadSDNode *LN0 =
- HasAnyExt ? cast<LoadSDNode>(N0.getOperand(0)) : cast<LoadSDNode>(N0);
-
- if (LN0->getExtensionType() == ISD::SEXTLOAD ||
- !LN0->isUnindexed() || !N0.hasOneUse() || !SDValue(LN0, 0).hasOneUse())
- return SDValue();
-
- auto N1C = dyn_cast<ConstantSDNode>(N->getOperand(1));
- if (!N1C)
+ // An AND with a constant mask is the same as a truncate + zero-extend.
+ auto AndC = dyn_cast<ConstantSDNode>(N->getOperand(1));
+ if (!AndC || !AndC->getAPIntValue().isMask())
return SDValue();
- EVT LoadedVT;
- bool NarrowLoad = false;
+ unsigned ActiveBits = AndC->getAPIntValue().countTrailingOnes();
ExtType = ISD::ZEXTLOAD;
- VT = HasAnyExt ? LN0->getValueType(0) : VT;
- if (!isAndLoadExtLoad(N1C, LN0, VT, ExtVT, LoadedVT, NarrowLoad))
- return SDValue();
-
- if (!NarrowLoad)
- return DAG.getExtLoad(ISD::ZEXTLOAD, SDLoc(LN0), VT,
- LN0->getChain(), LN0->getBasePtr(), ExtVT,
- LN0->getMemOperand());
+ ExtVT = EVT::getIntegerVT(*DAG.getContext(), ActiveBits);
}
if (LegalOperations && !TLI.isLoadExtLegal(ExtType, VT, ExtVT))
return SDValue();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40667.125186.patch
Type: text/x-patch
Size: 1685 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171201/3ea873e8/attachment.bin>
More information about the llvm-commits
mailing list