1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00

Fix this harder.

llvm-svn: 35888
This commit is contained in:
Chris Lattner 2007-04-11 06:50:51 +00:00
parent 01ebc25b36
commit 1d20292190

View File

@ -266,7 +266,8 @@ namespace {
SDOperand SimplifyBinOpWithSameOpcodeHands(SDNode *N); SDOperand SimplifyBinOpWithSameOpcodeHands(SDNode *N);
SDOperand SimplifySelect(SDOperand N0, SDOperand N1, SDOperand N2); SDOperand SimplifySelect(SDOperand N0, SDOperand N1, SDOperand N2);
SDOperand SimplifySelectCC(SDOperand N0, SDOperand N1, SDOperand N2, SDOperand SimplifySelectCC(SDOperand N0, SDOperand N1, SDOperand N2,
SDOperand N3, ISD::CondCode CC); SDOperand N3, ISD::CondCode CC,
bool NotExtCompare = false);
SDOperand SimplifySetCC(MVT::ValueType VT, SDOperand N0, SDOperand N1, SDOperand SimplifySetCC(MVT::ValueType VT, SDOperand N0, SDOperand N1,
ISD::CondCode Cond, bool foldBooleans = true); ISD::CondCode Cond, bool foldBooleans = true);
SDOperand ConstantFoldVBIT_CONVERTofVBUILD_VECTOR(SDNode *, MVT::ValueType); SDOperand ConstantFoldVBIT_CONVERTofVBUILD_VECTOR(SDNode *, MVT::ValueType);
@ -2133,10 +2134,10 @@ SDOperand DAGCombiner::visitSIGN_EXTEND(SDNode *N) {
// sext(setcc x,y,cc) -> select_cc x, y, -1, 0, cc // sext(setcc x,y,cc) -> select_cc x, y, -1, 0, cc
if (N0.getOpcode() == ISD::SETCC) { if (N0.getOpcode() == ISD::SETCC) {
SDOperand SCC = SDOperand SCC =
SimplifySelectCC(N0.getOperand(0), N0.getOperand(1), SimplifySelectCC(N0.getOperand(0), N0.getOperand(1),
DAG.getConstant(~0ULL, VT), DAG.getConstant(0, VT), DAG.getConstant(~0ULL, VT), DAG.getConstant(0, VT),
cast<CondCodeSDNode>(N0.getOperand(2))->get()); cast<CondCodeSDNode>(N0.getOperand(2))->get(), true);
if (SCC.Val && SCC.Val != N) return SCC; if (SCC.Val) return SCC;
} }
return SDOperand(); return SDOperand();
@ -2225,8 +2226,8 @@ SDOperand DAGCombiner::visitZERO_EXTEND(SDNode *N) {
SDOperand SCC = SDOperand SCC =
SimplifySelectCC(N0.getOperand(0), N0.getOperand(1), SimplifySelectCC(N0.getOperand(0), N0.getOperand(1),
DAG.getConstant(1, VT), DAG.getConstant(0, VT), DAG.getConstant(1, VT), DAG.getConstant(0, VT),
cast<CondCodeSDNode>(N0.getOperand(2))->get()); cast<CondCodeSDNode>(N0.getOperand(2))->get(), true);
if (SCC.Val && SCC.Val != N) return SCC; if (SCC.Val) return SCC;
} }
return SDOperand(); return SDOperand();
@ -2317,10 +2318,10 @@ SDOperand DAGCombiner::visitANY_EXTEND(SDNode *N) {
// aext(setcc x,y,cc) -> select_cc x, y, 1, 0, cc // aext(setcc x,y,cc) -> select_cc x, y, 1, 0, cc
if (N0.getOpcode() == ISD::SETCC) { if (N0.getOpcode() == ISD::SETCC) {
SDOperand SCC = SDOperand SCC =
SimplifySelectCC(N0.getOperand(0), N0.getOperand(1), SimplifySelectCC(N0.getOperand(0), N0.getOperand(1),
DAG.getConstant(1, VT), DAG.getConstant(0, VT), DAG.getConstant(1, VT), DAG.getConstant(0, VT),
cast<CondCodeSDNode>(N0.getOperand(2))->get()); cast<CondCodeSDNode>(N0.getOperand(2))->get());
if (SCC.Val && SCC.Val != N && SCC.getOpcode() != ISD::ZERO_EXTEND) if (SCC.Val)
return SCC; return SCC;
} }
@ -4047,7 +4048,7 @@ bool DAGCombiner::SimplifySelectOps(SDNode *TheSelect, SDOperand LHS,
SDOperand DAGCombiner::SimplifySelectCC(SDOperand N0, SDOperand N1, SDOperand DAGCombiner::SimplifySelectCC(SDOperand N0, SDOperand N1,
SDOperand N2, SDOperand N3, SDOperand N2, SDOperand N3,
ISD::CondCode CC) { ISD::CondCode CC, bool NotExtCompare) {
MVT::ValueType VT = N2.getValueType(); MVT::ValueType VT = N2.getValueType();
ConstantSDNode *N1C = dyn_cast<ConstantSDNode>(N1.Val); ConstantSDNode *N1C = dyn_cast<ConstantSDNode>(N1.Val);
@ -4123,6 +4124,12 @@ SDOperand DAGCombiner::SimplifySelectCC(SDOperand N0, SDOperand N1,
// fold select C, 16, 0 -> shl C, 4 // fold select C, 16, 0 -> shl C, 4
if (N2C && N3C && N3C->isNullValue() && isPowerOf2_64(N2C->getValue()) && if (N2C && N3C && N3C->isNullValue() && isPowerOf2_64(N2C->getValue()) &&
TLI.getSetCCResultContents() == TargetLowering::ZeroOrOneSetCCResult) { TLI.getSetCCResultContents() == TargetLowering::ZeroOrOneSetCCResult) {
// If the caller doesn't want us to simplify this into a zext of a compare,
// don't do it.
if (NotExtCompare && N2C->getValue() == 1)
return SDOperand();
// Get a SetCC of the condition // Get a SetCC of the condition
// FIXME: Should probably make sure that setcc is legal if we ever have a // FIXME: Should probably make sure that setcc is legal if we ever have a
// target where it isn't. // target where it isn't.