diff options
author | Sanjay Patel <spatel@rotateright.com> | 2019-07-24 15:43:50 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2019-07-24 15:43:50 +0000 |
commit | 10dad95a75592717d2f7c0ebc181fb8a970a8df7 (patch) | |
tree | 12f8a53b65666dfbebfcd146e5b3223413e60b6d /llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | |
parent | 0bf5f7082cc9b030f850496e428cb7957d6af381 (diff) | |
download | llvm-10dad95a75592717d2f7c0ebc181fb8a970a8df7.zip llvm-10dad95a75592717d2f7c0ebc181fb8a970a8df7.tar.gz llvm-10dad95a75592717d2f7c0ebc181fb8a970a8df7.tar.bz2 |
[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
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp index dc2348f..d6ac17e 100644 --- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -2876,9 +2876,9 @@ SDValue TargetLowering::SimplifySetCC(EVT VT, SDValue N0, SDValue N1, // (ctpop x) u< 2 -> (x & x-1) == 0 // (ctpop x) u> 1 -> (x & x-1) != 0 if ((Cond == ISD::SETULT && C1 == 2) || (Cond == ISD::SETUGT && C1 == 1)){ - SDValue Sub = DAG.getNode(ISD::SUB, dl, CTVT, CTOp, - DAG.getConstant(1, dl, CTVT)); - SDValue And = DAG.getNode(ISD::AND, dl, CTVT, CTOp, Sub); + SDValue NegOne = DAG.getAllOnesConstant(dl, CTVT); + SDValue Add = DAG.getNode(ISD::ADD, dl, CTVT, CTOp, NegOne); + SDValue And = DAG.getNode(ISD::AND, dl, CTVT, CTOp, Add); ISD::CondCode CC = Cond == ISD::SETULT ? ISD::SETEQ : ISD::SETNE; return DAG.getSetCC(dl, VT, And, DAG.getConstant(0, dl, CTVT), CC); } |