diff options
author | Hans Wennborg <hans@chromium.org> | 2019-10-23 19:44:16 +0200 |
---|---|---|
committer | Hans Wennborg <hans@chromium.org> | 2019-10-23 19:52:02 +0200 |
commit | 684ebc605e0b7f8782e634e1bb3621a9b0ec674f (patch) | |
tree | e34b43bcbabff2a47e166cfecc09a8ad057370ca /llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | |
parent | d01fd2f35a02cb53a5d9d1a5342b5085c5dce66c (diff) | |
download | bcm5719-llvm-684ebc605e0b7f8782e634e1bb3621a9b0ec674f.tar.gz bcm5719-llvm-684ebc605e0b7f8782e634e1bb3621a9b0ec674f.zip |
Revert 4334892e7b "[DAGCombine][ARM] x ==/!= c -> (x - c) ==/!= 0 iff '-c' can be folded into the x node."
This broke various Windows builds, see comments on the Phabricator
review.
This also reverts the follow-up 20bf0cf.
> Summary:
> This fold, helps recover from the rest of the D62266 ARM regressions.
> https://rise4fun.com/Alive/TvpC
>
> Note that while the fold is quite flexible, i've restricted it
> to the single interesting pattern at the moment.
>
> Reviewers: efriedma, craig.topper, spatel, RKSimon, deadalnix
>
> Reviewed By: deadalnix
>
> Subscribers: javed.absar, kristof.beyls, llvm-commits
>
> Tags: #llvm
>
> Differential Revision: https://reviews.llvm.org/D62450
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp index 5af2663d29e..9ab1324533f 100644 --- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -3045,66 +3045,6 @@ SDValue TargetLowering::foldSetCCWithBinOp(EVT VT, SDValue N0, SDValue N1, return DAG.getSetCC(DL, VT, X, YShl1, Cond); } -/// x ==/!= c -> (x - c) ==/!= 0 iff '-c' can be folded into the x node. -SDValue TargetLowering::optimizeSetCCToComparisonWithZero( - EVT SCCVT, SDValue N0, ConstantSDNode *N1C, ISD::CondCode Cond, - DAGCombinerInfo &DCI, const SDLoc &DL) const { - assert((Cond == ISD::SETEQ || Cond == ISD::SETNE) && - "Only for equality-comparisons."); - - // The constant we are comparing with must be a non-zero, non-opaque constant. - if (N1C->isNullValue() || N1C->isOpaque()) - return SDValue(); - - // LHS should not be used elsewhere, to avoid creating an extra node. - if (!N0.hasOneUse()) - return SDValue(); - - // Will we able to fold the '-c' into 'x' node? - bool IsAdd; - switch (N0.getOpcode()) { - default: - return SDValue(); // Don't know about that node. - case ISD::ADD: - case ISD::SUB: - return SDValue(); // Let's not touch these. - case ISD::ADDCARRY: - IsAdd = true; - break; - case ISD::SUBCARRY: - IsAdd = false; - break; - } - - // Second operand must be a non-opaque constant. - ConstantSDNode *N01C = isConstOrConstSplat(N0.getOperand(1)); - if (!N01C || N01C->isOpaque()) - return SDValue(); - - // And let's be even more specific for now, it must be a zero constant. - // It is possible to relax this requirement, but a precise cost-model needed. - if (!N01C->isNullValue()) - return SDValue(); - - SelectionDAG &DAG = DCI.DAG; - EVT OpVT = N0.getValueType(); - - // (y + N01C) - N1C = y + (N01C - N1C) - // (y - N01C) - N1C = y - (N01C + N1C) - SDValue NewC = DAG.FoldConstantArithmetic(IsAdd ? ISD::SUB : ISD::ADD, DL, - OpVT, N01C, N1C); - assert(NewC && "Constant-folding failed!"); - - SmallVector<SDValue, 3> N0Ops(N0.getNode()->ops().begin(), - N0.getNode()->ops().end()); - N0Ops[1] = NewC; - - N0 = DAG.getNode(N0.getOpcode(), DL, N0->getVTList(), N0Ops); - - SDValue Zero = DAG.getConstant(0, DL, OpVT); - return DAG.getSetCC(DL, SCCVT, N0, Zero, Cond); -} - /// Try to simplify a setcc built with the specified operands and cc. If it is /// unable to simplify it, return a null SDValue. SDValue TargetLowering::SimplifySetCC(EVT VT, SDValue N0, SDValue N1, @@ -3638,11 +3578,6 @@ SDValue TargetLowering::SimplifySetCC(EVT VT, SDValue N0, SDValue N1, return CC; } - if (Cond == ISD::SETEQ || Cond == ISD::SETNE) - if (SDValue CC = - optimizeSetCCToComparisonWithZero(VT, N0, N1C, Cond, DCI, dl)) - return CC; - // If we have "setcc X, C0", check to see if we can shrink the immediate // by changing cc. // TODO: Support this for vectors after legalize ops. |