forked from OSchip/llvm-project
[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:
parent
0bf5f7082c
commit
10dad95a75
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue