From eedfbc4ab7df2b9ddeb0674e8ef75c3cac550384 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Thu, 1 Mar 2018 22:15:39 +0000 Subject: [SelectionDAG] Support some SimplifySetCC cases for comparing against vector splats of constants. This supports things like (setcc ugt X, 0) -> (setcc ne X, 0) I've restricted to only make changes to vectors before legalize ops because I doubt all targets have accurate condition code legality information for vectors given how little we did before. Differential Revision: https://reviews.llvm.org/D42948 llvm-svn: 326495 --- llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp') diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp index cb737dcd787..75a2be4659f 100644 --- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -2221,7 +2221,8 @@ SDValue TargetLowering::SimplifySetCC(EVT VT, SDValue N0, SDValue N1, if (C1 == MinVal) return DAG.getBoolConstant(false, dl, VT, OpVT); // X < MIN --> false - if (!VT.isVector()) { // TODO: Support this for vectors. + // TODO: Support this for vectors after legalize ops. + if (!VT.isVector() || DCI.isBeforeLegalizeOps()) { // Canonicalize setlt X, Max --> setne X, Max if (C1 == MaxVal) return DAG.getSetCC(dl, VT, N0, N1, ISD::SETNE); @@ -2238,7 +2239,8 @@ SDValue TargetLowering::SimplifySetCC(EVT VT, SDValue N0, SDValue N1, if (C1 == MaxVal) return DAG.getBoolConstant(false, dl, VT, OpVT); // X > MAX --> false - if (!VT.isVector()) { // TODO: Support this for vectors. + // TODO: Support this for vectors after legalize ops. + if (!VT.isVector() || DCI.isBeforeLegalizeOps()) { // Canonicalize setgt X, Min --> setne X, Min if (C1 == MinVal) return DAG.getSetCC(dl, VT, N0, N1, ISD::SETNE); @@ -2253,7 +2255,8 @@ SDValue TargetLowering::SimplifySetCC(EVT VT, SDValue N0, SDValue N1, // If we have "setcc X, C0", check to see if we can shrink the immediate // by changing cc. - if (!VT.isVector()) { // TODO: Support this for vectors. + // TODO: Support this for vectors after legalize ops. + if (!VT.isVector() || DCI.isBeforeLegalizeOps()) { // SETUGT X, SINTMAX -> SETLT X, 0 if (Cond == ISD::SETUGT && C1 == APInt::getSignedMaxValue(OperandBitSize)) -- cgit v1.2.3