[SelectionDAG][NFC] Fix return type when used isConstantIntBuildVectorOrConstantInt

and isConstantFPBuildVectorOrConstantFP

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D131870
This commit is contained in:
wanglian 2022-08-16 10:01:08 +08:00
parent 29fe204b4e
commit fbc4c26e9a
2 changed files with 19 additions and 13 deletions

View File

@ -14697,8 +14697,8 @@ SDValue DAGCombiner::visitFMULForFMADistributiveCombine(SDNode *N) {
SDValue DAGCombiner::visitFADD(SDNode *N) {
SDValue N0 = N->getOperand(0);
SDValue N1 = N->getOperand(1);
bool N0CFP = DAG.isConstantFPBuildVectorOrConstantFP(N0);
bool N1CFP = DAG.isConstantFPBuildVectorOrConstantFP(N1);
SDNode *N0CFP = DAG.isConstantFPBuildVectorOrConstantFP(N0);
SDNode *N1CFP = DAG.isConstantFPBuildVectorOrConstantFP(N1);
EVT VT = N->getValueType(0);
SDLoc DL(N);
const TargetOptions &Options = DAG.getTarget().Options;
@ -14795,8 +14795,10 @@ SDValue DAGCombiner::visitFADD(SDNode *N) {
// of rounding steps.
if (TLI.isOperationLegalOrCustom(ISD::FMUL, VT) && !N0CFP && !N1CFP) {
if (N0.getOpcode() == ISD::FMUL) {
bool CFP00 = DAG.isConstantFPBuildVectorOrConstantFP(N0.getOperand(0));
bool CFP01 = DAG.isConstantFPBuildVectorOrConstantFP(N0.getOperand(1));
SDNode *CFP00 =
DAG.isConstantFPBuildVectorOrConstantFP(N0.getOperand(0));
SDNode *CFP01 =
DAG.isConstantFPBuildVectorOrConstantFP(N0.getOperand(1));
// (fadd (fmul x, c), x) -> (fmul x, c+1)
if (CFP01 && !CFP00 && N0.getOperand(0) == N1) {
@ -14816,8 +14818,10 @@ SDValue DAGCombiner::visitFADD(SDNode *N) {
}
if (N1.getOpcode() == ISD::FMUL) {
bool CFP10 = DAG.isConstantFPBuildVectorOrConstantFP(N1.getOperand(0));
bool CFP11 = DAG.isConstantFPBuildVectorOrConstantFP(N1.getOperand(1));
SDNode *CFP10 =
DAG.isConstantFPBuildVectorOrConstantFP(N1.getOperand(0));
SDNode *CFP11 =
DAG.isConstantFPBuildVectorOrConstantFP(N1.getOperand(1));
// (fadd x, (fmul x, c)) -> (fmul x, c+1)
if (CFP11 && !CFP10 && N1.getOperand(0) == N0) {
@ -14837,7 +14841,8 @@ SDValue DAGCombiner::visitFADD(SDNode *N) {
}
if (N0.getOpcode() == ISD::FADD) {
bool CFP00 = DAG.isConstantFPBuildVectorOrConstantFP(N0.getOperand(0));
SDNode *CFP00 =
DAG.isConstantFPBuildVectorOrConstantFP(N0.getOperand(0));
// (fadd (fadd x, x), x) -> (fmul x, 3.0)
if (!CFP00 && N0.getOperand(0) == N0.getOperand(1) &&
(N0.getOperand(0) == N1)) {
@ -14847,7 +14852,8 @@ SDValue DAGCombiner::visitFADD(SDNode *N) {
}
if (N1.getOpcode() == ISD::FADD) {
bool CFP10 = DAG.isConstantFPBuildVectorOrConstantFP(N1.getOperand(0));
SDNode *CFP10 =
DAG.isConstantFPBuildVectorOrConstantFP(N1.getOperand(0));
// (fadd x, (fadd x, x)) -> (fmul x, 3.0)
if (!CFP10 && N1.getOperand(0) == N1.getOperand(1) &&
N1.getOperand(0) == N0) {

View File

@ -5933,11 +5933,11 @@ void SelectionDAG::canonicalizeCommutativeBinop(unsigned Opcode, SDValue &N1,
// Canonicalize:
// binop(const, nonconst) -> binop(nonconst, const)
bool IsN1C = isConstantIntBuildVectorOrConstantInt(N1);
bool IsN2C = isConstantIntBuildVectorOrConstantInt(N2);
bool IsN1CFP = isConstantFPBuildVectorOrConstantFP(N1);
bool IsN2CFP = isConstantFPBuildVectorOrConstantFP(N2);
if ((IsN1C && !IsN2C) || (IsN1CFP && !IsN2CFP))
SDNode *N1C = isConstantIntBuildVectorOrConstantInt(N1);
SDNode *N2C = isConstantIntBuildVectorOrConstantInt(N2);
SDNode *N1CFP = isConstantFPBuildVectorOrConstantFP(N1);
SDNode *N2CFP = isConstantFPBuildVectorOrConstantFP(N2);
if ((N1C && !N2C) || (N1CFP && !N2CFP))
std::swap(N1, N2);
// Canonicalize: