mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-12 17:25:49 +00:00
DAGCombiner: simplify by using condition variables; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225836 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -738,10 +738,9 @@ SDValue DAGCombiner::ReassociateOps(unsigned Opc, SDLoc DL,
|
|||||||
if (SDNode *L = isConstantBuildVectorOrConstantInt(N0.getOperand(1))) {
|
if (SDNode *L = isConstantBuildVectorOrConstantInt(N0.getOperand(1))) {
|
||||||
if (SDNode *R = isConstantBuildVectorOrConstantInt(N1)) {
|
if (SDNode *R = isConstantBuildVectorOrConstantInt(N1)) {
|
||||||
// reassoc. (op (op x, c1), c2) -> (op x, (op c1, c2))
|
// reassoc. (op (op x, c1), c2) -> (op x, (op c1, c2))
|
||||||
SDValue OpNode = DAG.FoldConstantArithmetic(Opc, VT, L, R);
|
if (SDValue OpNode = DAG.FoldConstantArithmetic(Opc, VT, L, R))
|
||||||
if (!OpNode.getNode())
|
return DAG.getNode(Opc, DL, VT, N0.getOperand(0), OpNode);
|
||||||
return SDValue();
|
return SDValue();
|
||||||
return DAG.getNode(Opc, DL, VT, N0.getOperand(0), OpNode);
|
|
||||||
}
|
}
|
||||||
if (N0.hasOneUse()) {
|
if (N0.hasOneUse()) {
|
||||||
// reassoc. (op (op x, c1), y) -> (op (op x, y), c1) iff x+c1 has one
|
// reassoc. (op (op x, c1), y) -> (op (op x, y), c1) iff x+c1 has one
|
||||||
@@ -759,10 +758,9 @@ SDValue DAGCombiner::ReassociateOps(unsigned Opc, SDLoc DL,
|
|||||||
if (SDNode *R = isConstantBuildVectorOrConstantInt(N1.getOperand(1))) {
|
if (SDNode *R = isConstantBuildVectorOrConstantInt(N1.getOperand(1))) {
|
||||||
if (SDNode *L = isConstantBuildVectorOrConstantInt(N0)) {
|
if (SDNode *L = isConstantBuildVectorOrConstantInt(N0)) {
|
||||||
// reassoc. (op c2, (op x, c1)) -> (op x, (op c1, c2))
|
// reassoc. (op c2, (op x, c1)) -> (op x, (op c1, c2))
|
||||||
SDValue OpNode = DAG.FoldConstantArithmetic(Opc, VT, R, L);
|
if (SDValue OpNode = DAG.FoldConstantArithmetic(Opc, VT, R, L))
|
||||||
if (!OpNode.getNode())
|
return DAG.getNode(Opc, DL, VT, N1.getOperand(0), OpNode);
|
||||||
return SDValue();
|
return SDValue();
|
||||||
return DAG.getNode(Opc, DL, VT, N1.getOperand(0), OpNode);
|
|
||||||
}
|
}
|
||||||
if (N1.hasOneUse()) {
|
if (N1.hasOneUse()) {
|
||||||
// reassoc. (op y, (op x, c1)) -> (op (op x, y), c1) iff x+c1 has one
|
// reassoc. (op y, (op x, c1)) -> (op (op x, y), c1) iff x+c1 has one
|
||||||
@@ -3449,12 +3447,11 @@ SDValue DAGCombiner::visitOR(SDNode *N) {
|
|||||||
isa<ConstantSDNode>(N0.getOperand(1))) {
|
isa<ConstantSDNode>(N0.getOperand(1))) {
|
||||||
ConstantSDNode *C1 = cast<ConstantSDNode>(N0.getOperand(1));
|
ConstantSDNode *C1 = cast<ConstantSDNode>(N0.getOperand(1));
|
||||||
if ((C1->getAPIntValue() & N1C->getAPIntValue()) != 0) {
|
if ((C1->getAPIntValue() & N1C->getAPIntValue()) != 0) {
|
||||||
SDValue COR = DAG.FoldConstantArithmetic(ISD::OR, VT, N1C, C1);
|
if (SDValue COR = DAG.FoldConstantArithmetic(ISD::OR, VT, N1C, C1))
|
||||||
if (!COR.getNode())
|
return DAG.getNode(
|
||||||
return SDValue();
|
ISD::AND, SDLoc(N), VT,
|
||||||
return DAG.getNode(ISD::AND, SDLoc(N), VT,
|
DAG.getNode(ISD::OR, SDLoc(N0), VT, N0.getOperand(0), N1), COR);
|
||||||
DAG.getNode(ISD::OR, SDLoc(N0), VT,
|
return SDValue();
|
||||||
N0.getOperand(0), N1), COR);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// fold (or (setcc x), (setcc y)) -> (setcc (or x, y))
|
// fold (or (setcc x), (setcc y)) -> (setcc (or x, y))
|
||||||
@@ -4070,8 +4067,7 @@ SDValue DAGCombiner::visitSHL(SDNode *N) {
|
|||||||
if (N01CV && N01CV->isConstant() && N00.getOpcode() == ISD::SETCC &&
|
if (N01CV && N01CV->isConstant() && N00.getOpcode() == ISD::SETCC &&
|
||||||
TLI.getBooleanContents(N00.getOperand(0).getValueType()) ==
|
TLI.getBooleanContents(N00.getOperand(0).getValueType()) ==
|
||||||
TargetLowering::ZeroOrNegativeOneBooleanContent) {
|
TargetLowering::ZeroOrNegativeOneBooleanContent) {
|
||||||
SDValue C = DAG.FoldConstantArithmetic(ISD::SHL, VT, N01CV, N1CV);
|
if (SDValue C = DAG.FoldConstantArithmetic(ISD::SHL, VT, N01CV, N1CV))
|
||||||
if (C.getNode())
|
|
||||||
return DAG.getNode(ISD::AND, SDLoc(N), VT, N00, C);
|
return DAG.getNode(ISD::AND, SDLoc(N), VT, N00, C);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@@ -3383,8 +3383,9 @@ SDValue SelectionDAG::getNode(unsigned Opcode, SDLoc DL, EVT VT, SDValue N1,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Perform trivial constant folding.
|
// Perform trivial constant folding.
|
||||||
SDValue SV = FoldConstantArithmetic(Opcode, VT, N1.getNode(), N2.getNode());
|
if (SDValue SV =
|
||||||
if (SV.getNode()) return SV;
|
FoldConstantArithmetic(Opcode, VT, N1.getNode(), N2.getNode()))
|
||||||
|
return SV;
|
||||||
|
|
||||||
// Canonicalize constant to RHS if commutative.
|
// Canonicalize constant to RHS if commutative.
|
||||||
if (N1C && !N2C && isCommutativeBinOp(Opcode)) {
|
if (N1C && !N2C && isCommutativeBinOp(Opcode)) {
|
||||||
|
Reference in New Issue
Block a user