From bd8625b062c468ccd62b713993a45e8dd40e67a7 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 9 Aug 2005 23:09:05 +0000 Subject: [PATCH] Fix spelling, fix some broken canonicalizations by my last patch git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22734 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index c23c145d641..c2d5de841ef 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -386,8 +386,8 @@ SDOperand SelectionDAG::getCondCode(ISD::CondCode Cond) { return SDOperand(CondCodeNodes[Cond], 0); } -SDOperand SelectionDAG::SimplfySetCC(MVT::ValueType VT, SDOperand N1, - SDOperand N2, ISD::CondCode Cond) { +SDOperand SelectionDAG::SimplifySetCC(MVT::ValueType VT, SDOperand N1, + SDOperand N2, ISD::CondCode Cond) { // These setcc operations always fold. switch (Cond) { default: break; @@ -484,17 +484,15 @@ SDOperand SelectionDAG::SimplfySetCC(MVT::ValueType VT, SDOperand N1, if (Cond == ISD::SETGE || Cond == ISD::SETUGE) { if (C2 == MinVal) return getConstant(1, VT); // X >= MIN --> true --C2; // X >= C1 --> X > (C1-1) - Cond = (Cond == ISD::SETGE) ? ISD::SETGT : ISD::SETUGT; - N2 = getConstant(C2, N2.getValueType()); - N2C = cast(N2.Val); + return getSetCC(VT, N1, getConstant(C2, N2.getValueType()), + (Cond == ISD::SETGE) ? ISD::SETGT : ISD::SETUGT); } if (Cond == ISD::SETLE || Cond == ISD::SETULE) { if (C2 == MaxVal) return getConstant(1, VT); // X <= MAX --> true ++C2; // X <= C1 --> X < (C1+1) - Cond = (Cond == ISD::SETLE) ? ISD::SETLT : ISD::SETULT; - N2 = getConstant(C2, N2.getValueType()); - N2C = cast(N2.Val); + return getSetCC(VT, N1, getConstant(C2, N2.getValueType()), + (Cond == ISD::SETLE) ? ISD::SETLT : ISD::SETULT); } if ((Cond == ISD::SETLT || Cond == ISD::SETULT) && C2 == MinVal) @@ -566,8 +564,7 @@ SDOperand SelectionDAG::SimplfySetCC(MVT::ValueType VT, SDOperand N1, } } else { // Ensure that the constant occurs on the RHS. - Cond = ISD::getSetCCSwappedOperands(Cond); - std::swap(N1, N2); + return getSetCC(VT, N2, N1, ISD::getSetCCSwappedOperands(Cond)); } if (N1 == N2) { @@ -581,7 +578,9 @@ SDOperand SelectionDAG::SimplfySetCC(MVT::ValueType VT, SDOperand N1, return getConstant(UOF, VT); // Otherwise, we can't fold it. However, we can simplify it to SETUO/SETO // if it is not already. - Cond = UOF == 0 ? ISD::SETUO : ISD::SETO; + ISD::CondCode NewCond = UOF == 0 ? ISD::SETUO : ISD::SETO; + if (NewCond != Cond) + return getSetCC(VT, N1, N2, NewCond); } if ((Cond == ISD::SETEQ || Cond == ISD::SETNE) && @@ -1356,7 +1355,7 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT, switch (Opcode) { case ISD::SETCC: { // Use SimplifySetCC to simplify SETCC's. - SDOperand Simp = SimplfySetCC(VT, N1, N2, cast(N3)->get()); + SDOperand Simp = SimplifySetCC(VT, N1, N2, cast(N3)->get()); if (Simp.Val) return Simp; break; } -- 2.34.1