mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-15 04:30:12 +00:00
Add comment, clean up code. No functional change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162107 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b97cebdfcc
commit
1f1ab3e9c4
@ -6973,6 +6973,27 @@ void ARMTargetLowering::AdjustInstrPostInstrSelection(MachineInstr *MI,
|
|||||||
// ARM Optimization Hooks
|
// ARM Optimization Hooks
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
// Helper function that checks if N is a null or all ones constant.
|
||||||
|
static inline bool isZeroOrAllOnes(SDValue N, bool AllOnes) {
|
||||||
|
ConstantSDNode *C = dyn_cast<ConstantSDNode>(N);
|
||||||
|
if (!C)
|
||||||
|
return false;
|
||||||
|
return AllOnes ? C->isAllOnesValue() : C->isNullValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Combine a constant select operand into its use:
|
||||||
|
//
|
||||||
|
// (add (select cc, 0, c), x) -> (select cc, x, (add, x, c))
|
||||||
|
// (sub x, (select cc, 0, c)) -> (select cc, x, (sub, x, c))
|
||||||
|
//
|
||||||
|
// The transform is rejected if the select doesn't have a constant operand that
|
||||||
|
// is null.
|
||||||
|
//
|
||||||
|
// @param N The node to transform.
|
||||||
|
// @param Slct The N operand that is a select.
|
||||||
|
// @param OtherOp The other N operand (x above).
|
||||||
|
// @param DCI Context.
|
||||||
|
// @returns The new node, or SDValue() on failure.
|
||||||
static
|
static
|
||||||
SDValue combineSelectAndUse(SDNode *N, SDValue Slct, SDValue OtherOp,
|
SDValue combineSelectAndUse(SDNode *N, SDValue Slct, SDValue OtherOp,
|
||||||
TargetLowering::DAGCombinerInfo &DCI) {
|
TargetLowering::DAGCombinerInfo &DCI) {
|
||||||
@ -6998,16 +7019,12 @@ SDValue combineSelectAndUse(SDNode *N, SDValue Slct, SDValue OtherOp,
|
|||||||
assert ((Opc == ISD::ADD || (Opc == ISD::SUB && Slct == N->getOperand(1))) &&
|
assert ((Opc == ISD::ADD || (Opc == ISD::SUB && Slct == N->getOperand(1))) &&
|
||||||
"Bad input!");
|
"Bad input!");
|
||||||
|
|
||||||
if (LHS.getOpcode() == ISD::Constant &&
|
if (isZeroOrAllOnes(LHS, false)) {
|
||||||
cast<ConstantSDNode>(LHS)->isNullValue()) {
|
|
||||||
DoXform = true;
|
DoXform = true;
|
||||||
} else if (CC != ISD::SETCC_INVALID &&
|
} else if (CC != ISD::SETCC_INVALID && isZeroOrAllOnes(RHS, false)) {
|
||||||
RHS.getOpcode() == ISD::Constant &&
|
|
||||||
cast<ConstantSDNode>(RHS)->isNullValue()) {
|
|
||||||
std::swap(LHS, RHS);
|
std::swap(LHS, RHS);
|
||||||
SDValue Op0 = Slct.getOperand(0);
|
SDValue Op0 = Slct.getOperand(0);
|
||||||
EVT OpVT = isSlctCC ? Op0.getValueType() :
|
EVT OpVT = isSlctCC ? Op0.getValueType() : Op0.getOperand(0).getValueType();
|
||||||
Op0.getOperand(0).getValueType();
|
|
||||||
bool isInt = OpVT.isInteger();
|
bool isInt = OpVT.isInteger();
|
||||||
CC = ISD::getSetCCInverse(CC, isInt);
|
CC = ISD::getSetCCInverse(CC, isInt);
|
||||||
|
|
||||||
@ -7018,7 +7035,9 @@ SDValue combineSelectAndUse(SDNode *N, SDValue Slct, SDValue OtherOp,
|
|||||||
InvCC = true;
|
InvCC = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DoXform) {
|
if (!DoXform)
|
||||||
|
return SDValue();
|
||||||
|
|
||||||
SDValue Result = DAG.getNode(Opc, RHS.getDebugLoc(), VT, OtherOp, RHS);
|
SDValue Result = DAG.getNode(Opc, RHS.getDebugLoc(), VT, OtherOp, RHS);
|
||||||
if (isSlctCC)
|
if (isSlctCC)
|
||||||
return DAG.getSelectCC(N->getDebugLoc(), OtherOp, Result,
|
return DAG.getSelectCC(N->getDebugLoc(), OtherOp, Result,
|
||||||
@ -7029,8 +7048,6 @@ SDValue combineSelectAndUse(SDNode *N, SDValue Slct, SDValue OtherOp,
|
|||||||
CCOp.getOperand(0), CCOp.getOperand(1), CC);
|
CCOp.getOperand(0), CCOp.getOperand(1), CC);
|
||||||
return DAG.getNode(ISD::SELECT, N->getDebugLoc(), VT,
|
return DAG.getNode(ISD::SELECT, N->getDebugLoc(), VT,
|
||||||
CCOp, OtherOp, Result);
|
CCOp, OtherOp, Result);
|
||||||
}
|
|
||||||
return SDValue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddCombineToVPADDL- For pair-wise add on neon, use the vpaddl instruction
|
// AddCombineToVPADDL- For pair-wise add on neon, use the vpaddl instruction
|
||||||
@ -7297,16 +7314,8 @@ static SDValue PerformMULCombine(SDNode *N,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool isCMOVWithZeroOrAllOnesLHS(SDValue N, bool AllOnes) {
|
static bool isCMOVWithZeroOrAllOnesLHS(SDValue N, bool AllOnes) {
|
||||||
if (N.getOpcode() != ARMISD::CMOV || !N.getNode()->hasOneUse())
|
return N.getOpcode() == ARMISD::CMOV && N.getNode()->hasOneUse() &&
|
||||||
return false;
|
isZeroOrAllOnes(N.getOperand(0), AllOnes);
|
||||||
|
|
||||||
SDValue FalseVal = N.getOperand(0);
|
|
||||||
ConstantSDNode *C = dyn_cast<ConstantSDNode>(FalseVal);
|
|
||||||
if (!C)
|
|
||||||
return false;
|
|
||||||
if (AllOnes)
|
|
||||||
return C->isAllOnesValue();
|
|
||||||
return C->isNullValue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// formConditionalOp - Combine an operation with a conditional move operand
|
/// formConditionalOp - Combine an operation with a conditional move operand
|
||||||
|
Loading…
Reference in New Issue
Block a user