[PATCH] D54285: [DAGCombiner] Enable tryToFoldExtendOfConstant to run between legalize vector ops and legalize DAG
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 8 17:15:29 PST 2018
craig.topper created this revision.
craig.topper added reviewers: RKSimon, spatel, efriedma.
I believe it should be ok to create a new build_vector before legalize DAG since we don't legalize any build_vectors until legalize DAG.
I've added a new flag to DAGCombiner to reflect this level in a bool so we can pass it so the function without doing a compare to Level variable at each call site.
Unfortunately, X86's custom constant folding in combineVSZext is hiding any test changes from this. But I'm trying to get to a point where that X86 specific code isn't necessary at all.
https://reviews.llvm.org/D54285
Files:
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Index: lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -119,6 +119,7 @@
const TargetLowering &TLI;
CombineLevel Level;
CodeGenOpt::Level OptLevel;
+ bool LegalDAG = false;
bool LegalOperations = false;
bool LegalTypes = false;
bool ForCodeSize;
@@ -1404,6 +1405,7 @@
void DAGCombiner::Run(CombineLevel AtLevel) {
// set the instance variables, so that the various visit routines may use it.
Level = AtLevel;
+ LegalDAG = Level >= AfterLegalizeDAG;
LegalOperations = Level >= AfterLegalizeVectorOps;
LegalTypes = Level >= AfterLegalizeTypes;
@@ -8024,7 +8026,7 @@
/// avoid introducing illegal build_vector dag nodes.
static SDNode *tryToFoldExtendOfConstant(SDNode *N, const TargetLowering &TLI,
SelectionDAG &DAG, bool LegalTypes,
- bool LegalOperations) {
+ bool LegalDAG) {
unsigned Opcode = N->getOpcode();
SDValue N0 = N->getOperand(0);
EVT VT = N->getValueType(0);
@@ -8045,7 +8047,7 @@
// fold (aext (build_vector AllConstants) -> (build_vector AllConstants)
EVT SVT = VT.getScalarType();
if (!(VT.isVector() &&
- (!LegalTypes || (!LegalOperations && TLI.isTypeLegal(SVT))) &&
+ (!LegalTypes || (!LegalDAG && TLI.isTypeLegal(SVT))) &&
ISD::isBuildVectorOfConstantSDNodes(N0.getNode())))
return nullptr;
@@ -8480,7 +8482,7 @@
SDLoc DL(N);
if (SDNode *Res = tryToFoldExtendOfConstant(N, TLI, DAG, LegalTypes,
- LegalOperations))
+ LegalDAG))
return SDValue(Res, 0);
// fold (sext (sext x)) -> (sext x)
@@ -8719,7 +8721,7 @@
EVT VT = N->getValueType(0);
if (SDNode *Res = tryToFoldExtendOfConstant(N, TLI, DAG, LegalTypes,
- LegalOperations))
+ LegalDAG))
return SDValue(Res, 0);
// fold (zext (zext x)) -> (zext x)
@@ -8969,7 +8971,7 @@
EVT VT = N->getValueType(0);
if (SDNode *Res = tryToFoldExtendOfConstant(N, TLI, DAG, LegalTypes,
- LegalOperations))
+ LegalDAG))
return SDValue(Res, 0);
// fold (aext (aext x)) -> (aext x)
@@ -9496,7 +9498,7 @@
return DAG.getUNDEF(VT);
if (SDNode *Res = tryToFoldExtendOfConstant(N, TLI, DAG, LegalTypes,
- LegalOperations))
+ LegalDAG))
return SDValue(Res, 0);
return SDValue();
@@ -9510,7 +9512,7 @@
return DAG.getUNDEF(VT);
if (SDNode *Res = tryToFoldExtendOfConstant(N, TLI, DAG, LegalTypes,
- LegalOperations))
+ LegalDAG))
return SDValue(Res, 0);
return SDValue();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54285.173250.patch
Type: text/x-patch
Size: 3128 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181109/d153819a/attachment.bin>
More information about the llvm-commits
mailing list