[SDAG] convert (sub x, 1) to (add x, -1) in ctpop expansion; NFC

We canonicalize to the add form, so create that directly for efficiency.

llvm-svn: 366914
This commit is contained in:
Sanjay Patel 2019-07-24 15:43:50 +00:00
parent 0bf5f7082c
commit 10dad95a75
1 changed files with 3 additions and 3 deletions

View File

@ -2876,9 +2876,9 @@ SDValue TargetLowering::SimplifySetCC(EVT VT, SDValue N0, SDValue N1,
// (ctpop x) u< 2 -> (x & x-1) == 0 // (ctpop x) u< 2 -> (x & x-1) == 0
// (ctpop x) u> 1 -> (x & x-1) != 0 // (ctpop x) u> 1 -> (x & x-1) != 0
if ((Cond == ISD::SETULT && C1 == 2) || (Cond == ISD::SETUGT && C1 == 1)){ if ((Cond == ISD::SETULT && C1 == 2) || (Cond == ISD::SETUGT && C1 == 1)){
SDValue Sub = DAG.getNode(ISD::SUB, dl, CTVT, CTOp, SDValue NegOne = DAG.getAllOnesConstant(dl, CTVT);
DAG.getConstant(1, dl, CTVT)); SDValue Add = DAG.getNode(ISD::ADD, dl, CTVT, CTOp, NegOne);
SDValue And = DAG.getNode(ISD::AND, dl, CTVT, CTOp, Sub); SDValue And = DAG.getNode(ISD::AND, dl, CTVT, CTOp, Add);
ISD::CondCode CC = Cond == ISD::SETULT ? ISD::SETEQ : ISD::SETNE; ISD::CondCode CC = Cond == ISD::SETULT ? ISD::SETEQ : ISD::SETNE;
return DAG.getSetCC(dl, VT, And, DAG.getConstant(0, dl, CTVT), CC); return DAG.getSetCC(dl, VT, And, DAG.getConstant(0, dl, CTVT), CC);
} }