forked from OSchip/llvm-project
[DAGCombiner] Make tryToFoldExtendOfConstant return an SDValue instead of an SDNode*. NFC
Removes the need to call getNode internally and to recreate an SDValue after the call. llvm-svn: 346600
This commit is contained in:
parent
f8d480b12c
commit
d23cdbbeb2
|
@ -8022,7 +8022,7 @@ SDValue DAGCombiner::visitSETCCCARRY(SDNode *N) {
|
||||||
/// dag nodes (see for example method DAGCombiner::visitSIGN_EXTEND).
|
/// dag nodes (see for example method DAGCombiner::visitSIGN_EXTEND).
|
||||||
/// Vector extends are not folded if operations are legal; this is to
|
/// Vector extends are not folded if operations are legal; this is to
|
||||||
/// avoid introducing illegal build_vector dag nodes.
|
/// avoid introducing illegal build_vector dag nodes.
|
||||||
static SDNode *tryToFoldExtendOfConstant(SDNode *N, const TargetLowering &TLI,
|
static SDValue tryToFoldExtendOfConstant(SDNode *N, const TargetLowering &TLI,
|
||||||
SelectionDAG &DAG, bool LegalTypes,
|
SelectionDAG &DAG, bool LegalTypes,
|
||||||
bool LegalOperations) {
|
bool LegalOperations) {
|
||||||
unsigned Opcode = N->getOpcode();
|
unsigned Opcode = N->getOpcode();
|
||||||
|
@ -8038,7 +8038,7 @@ static SDNode *tryToFoldExtendOfConstant(SDNode *N, const TargetLowering &TLI,
|
||||||
// fold (zext c1) -> c1
|
// fold (zext c1) -> c1
|
||||||
// fold (aext c1) -> c1
|
// fold (aext c1) -> c1
|
||||||
if (isa<ConstantSDNode>(N0))
|
if (isa<ConstantSDNode>(N0))
|
||||||
return DAG.getNode(Opcode, SDLoc(N), VT, N0).getNode();
|
return DAG.getNode(Opcode, SDLoc(N), VT, N0);
|
||||||
|
|
||||||
// fold (sext (build_vector AllConstants) -> (build_vector AllConstants)
|
// fold (sext (build_vector AllConstants) -> (build_vector AllConstants)
|
||||||
// fold (zext (build_vector AllConstants) -> (build_vector AllConstants)
|
// fold (zext (build_vector AllConstants) -> (build_vector AllConstants)
|
||||||
|
@ -8047,7 +8047,7 @@ static SDNode *tryToFoldExtendOfConstant(SDNode *N, const TargetLowering &TLI,
|
||||||
if (!(VT.isVector() &&
|
if (!(VT.isVector() &&
|
||||||
(!LegalTypes || (!LegalOperations && TLI.isTypeLegal(SVT))) &&
|
(!LegalTypes || (!LegalOperations && TLI.isTypeLegal(SVT))) &&
|
||||||
ISD::isBuildVectorOfConstantSDNodes(N0.getNode())))
|
ISD::isBuildVectorOfConstantSDNodes(N0.getNode())))
|
||||||
return nullptr;
|
return SDValue();
|
||||||
|
|
||||||
// We can fold this node into a build_vector.
|
// We can fold this node into a build_vector.
|
||||||
unsigned VTBits = SVT.getSizeInBits();
|
unsigned VTBits = SVT.getSizeInBits();
|
||||||
|
@ -8073,7 +8073,7 @@ static SDNode *tryToFoldExtendOfConstant(SDNode *N, const TargetLowering &TLI,
|
||||||
Elts.push_back(DAG.getConstant(C.zext(VTBits), DL, SVT));
|
Elts.push_back(DAG.getConstant(C.zext(VTBits), DL, SVT));
|
||||||
}
|
}
|
||||||
|
|
||||||
return DAG.getBuildVector(VT, DL, Elts).getNode();
|
return DAG.getBuildVector(VT, DL, Elts);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExtendUsesToFormExtLoad - Trying to extend uses of a load to enable this:
|
// ExtendUsesToFormExtLoad - Trying to extend uses of a load to enable this:
|
||||||
|
@ -8479,9 +8479,9 @@ SDValue DAGCombiner::visitSIGN_EXTEND(SDNode *N) {
|
||||||
EVT VT = N->getValueType(0);
|
EVT VT = N->getValueType(0);
|
||||||
SDLoc DL(N);
|
SDLoc DL(N);
|
||||||
|
|
||||||
if (SDNode *Res = tryToFoldExtendOfConstant(N, TLI, DAG, LegalTypes,
|
if (SDValue Res = tryToFoldExtendOfConstant(N, TLI, DAG, LegalTypes,
|
||||||
LegalOperations))
|
LegalOperations))
|
||||||
return SDValue(Res, 0);
|
return Res;
|
||||||
|
|
||||||
// fold (sext (sext x)) -> (sext x)
|
// fold (sext (sext x)) -> (sext x)
|
||||||
// fold (sext (aext x)) -> (sext x)
|
// fold (sext (aext x)) -> (sext x)
|
||||||
|
@ -8718,9 +8718,9 @@ SDValue DAGCombiner::visitZERO_EXTEND(SDNode *N) {
|
||||||
SDValue N0 = N->getOperand(0);
|
SDValue N0 = N->getOperand(0);
|
||||||
EVT VT = N->getValueType(0);
|
EVT VT = N->getValueType(0);
|
||||||
|
|
||||||
if (SDNode *Res = tryToFoldExtendOfConstant(N, TLI, DAG, LegalTypes,
|
if (SDValue Res = tryToFoldExtendOfConstant(N, TLI, DAG, LegalTypes,
|
||||||
LegalOperations))
|
LegalOperations))
|
||||||
return SDValue(Res, 0);
|
return Res;
|
||||||
|
|
||||||
// fold (zext (zext x)) -> (zext x)
|
// fold (zext (zext x)) -> (zext x)
|
||||||
// fold (zext (aext x)) -> (zext x)
|
// fold (zext (aext x)) -> (zext x)
|
||||||
|
@ -8968,9 +8968,9 @@ SDValue DAGCombiner::visitANY_EXTEND(SDNode *N) {
|
||||||
SDValue N0 = N->getOperand(0);
|
SDValue N0 = N->getOperand(0);
|
||||||
EVT VT = N->getValueType(0);
|
EVT VT = N->getValueType(0);
|
||||||
|
|
||||||
if (SDNode *Res = tryToFoldExtendOfConstant(N, TLI, DAG, LegalTypes,
|
if (SDValue Res = tryToFoldExtendOfConstant(N, TLI, DAG, LegalTypes,
|
||||||
LegalOperations))
|
LegalOperations))
|
||||||
return SDValue(Res, 0);
|
return Res;
|
||||||
|
|
||||||
// fold (aext (aext x)) -> (aext x)
|
// fold (aext (aext x)) -> (aext x)
|
||||||
// fold (aext (zext x)) -> (zext x)
|
// fold (aext (zext x)) -> (zext x)
|
||||||
|
@ -9495,9 +9495,9 @@ SDValue DAGCombiner::visitSIGN_EXTEND_VECTOR_INREG(SDNode *N) {
|
||||||
if (N0.isUndef())
|
if (N0.isUndef())
|
||||||
return DAG.getUNDEF(VT);
|
return DAG.getUNDEF(VT);
|
||||||
|
|
||||||
if (SDNode *Res = tryToFoldExtendOfConstant(N, TLI, DAG, LegalTypes,
|
if (SDValue Res = tryToFoldExtendOfConstant(N, TLI, DAG, LegalTypes,
|
||||||
LegalOperations))
|
LegalOperations))
|
||||||
return SDValue(Res, 0);
|
return Res;
|
||||||
|
|
||||||
return SDValue();
|
return SDValue();
|
||||||
}
|
}
|
||||||
|
@ -9509,9 +9509,9 @@ SDValue DAGCombiner::visitZERO_EXTEND_VECTOR_INREG(SDNode *N) {
|
||||||
if (N0.isUndef())
|
if (N0.isUndef())
|
||||||
return DAG.getUNDEF(VT);
|
return DAG.getUNDEF(VT);
|
||||||
|
|
||||||
if (SDNode *Res = tryToFoldExtendOfConstant(N, TLI, DAG, LegalTypes,
|
if (SDValue Res = tryToFoldExtendOfConstant(N, TLI, DAG, LegalTypes,
|
||||||
LegalOperations))
|
LegalOperations))
|
||||||
return SDValue(Res, 0);
|
return Res;
|
||||||
|
|
||||||
return SDValue();
|
return SDValue();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue