forked from OSchip/llvm-project
[DAGCombiner] Enable tryToFoldExtendOfConstant to run after legalize vector ops
It should be ok to create a new build_vector after legal operations so long as it doesn't cause an infinite loop in DAG combiner. 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. Differential Revision: https://reviews.llvm.org/D54285 llvm-svn: 346728
This commit is contained in:
parent
8bf69be1c1
commit
0b33b468a1
|
@ -8023,8 +8023,7 @@ SDValue DAGCombiner::visitSETCCCARRY(SDNode *N) {
|
|||
/// Vector extends are not folded if operations are legal; this is to
|
||||
/// avoid introducing illegal build_vector dag nodes.
|
||||
static SDValue tryToFoldExtendOfConstant(SDNode *N, const TargetLowering &TLI,
|
||||
SelectionDAG &DAG, bool LegalTypes,
|
||||
bool LegalOperations) {
|
||||
SelectionDAG &DAG, bool LegalTypes) {
|
||||
unsigned Opcode = N->getOpcode();
|
||||
SDValue N0 = N->getOperand(0);
|
||||
EVT VT = N->getValueType(0);
|
||||
|
@ -8044,8 +8043,7 @@ static SDValue tryToFoldExtendOfConstant(SDNode *N, const TargetLowering &TLI,
|
|||
// fold (zext (build_vector AllConstants) -> (build_vector AllConstants)
|
||||
// fold (aext (build_vector AllConstants) -> (build_vector AllConstants)
|
||||
EVT SVT = VT.getScalarType();
|
||||
if (!(VT.isVector() &&
|
||||
(!LegalTypes || (!LegalOperations && TLI.isTypeLegal(SVT))) &&
|
||||
if (!(VT.isVector() && (!LegalTypes || TLI.isTypeLegal(SVT)) &&
|
||||
ISD::isBuildVectorOfConstantSDNodes(N0.getNode())))
|
||||
return SDValue();
|
||||
|
||||
|
@ -8479,8 +8477,7 @@ SDValue DAGCombiner::visitSIGN_EXTEND(SDNode *N) {
|
|||
EVT VT = N->getValueType(0);
|
||||
SDLoc DL(N);
|
||||
|
||||
if (SDValue Res = tryToFoldExtendOfConstant(N, TLI, DAG, LegalTypes,
|
||||
LegalOperations))
|
||||
if (SDValue Res = tryToFoldExtendOfConstant(N, TLI, DAG, LegalTypes))
|
||||
return Res;
|
||||
|
||||
// fold (sext (sext x)) -> (sext x)
|
||||
|
@ -8718,8 +8715,7 @@ SDValue DAGCombiner::visitZERO_EXTEND(SDNode *N) {
|
|||
SDValue N0 = N->getOperand(0);
|
||||
EVT VT = N->getValueType(0);
|
||||
|
||||
if (SDValue Res = tryToFoldExtendOfConstant(N, TLI, DAG, LegalTypes,
|
||||
LegalOperations))
|
||||
if (SDValue Res = tryToFoldExtendOfConstant(N, TLI, DAG, LegalTypes))
|
||||
return Res;
|
||||
|
||||
// fold (zext (zext x)) -> (zext x)
|
||||
|
@ -8968,8 +8964,7 @@ SDValue DAGCombiner::visitANY_EXTEND(SDNode *N) {
|
|||
SDValue N0 = N->getOperand(0);
|
||||
EVT VT = N->getValueType(0);
|
||||
|
||||
if (SDValue Res = tryToFoldExtendOfConstant(N, TLI, DAG, LegalTypes,
|
||||
LegalOperations))
|
||||
if (SDValue Res = tryToFoldExtendOfConstant(N, TLI, DAG, LegalTypes))
|
||||
return Res;
|
||||
|
||||
// fold (aext (aext x)) -> (aext x)
|
||||
|
@ -9495,8 +9490,7 @@ SDValue DAGCombiner::visitSIGN_EXTEND_VECTOR_INREG(SDNode *N) {
|
|||
if (N0.isUndef())
|
||||
return DAG.getUNDEF(VT);
|
||||
|
||||
if (SDValue Res = tryToFoldExtendOfConstant(N, TLI, DAG, LegalTypes,
|
||||
LegalOperations))
|
||||
if (SDValue Res = tryToFoldExtendOfConstant(N, TLI, DAG, LegalTypes))
|
||||
return Res;
|
||||
|
||||
return SDValue();
|
||||
|
@ -9509,8 +9503,7 @@ SDValue DAGCombiner::visitZERO_EXTEND_VECTOR_INREG(SDNode *N) {
|
|||
if (N0.isUndef())
|
||||
return DAG.getUNDEF(VT);
|
||||
|
||||
if (SDValue Res = tryToFoldExtendOfConstant(N, TLI, DAG, LegalTypes,
|
||||
LegalOperations))
|
||||
if (SDValue Res = tryToFoldExtendOfConstant(N, TLI, DAG, LegalTypes))
|
||||
return Res;
|
||||
|
||||
return SDValue();
|
||||
|
|
Loading…
Reference in New Issue