[PATCH] D92246: [DAGCombiner][NFC] Replace duplicate implementation flipBoolean with DAG.getLogicalNot
Layton Kifer via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 27 13:04:07 PST 2020
laytonio created this revision.
laytonio added reviewers: RKSimon, craig.topper, spatel, lebedev.ri.
Herald added subscribers: llvm-commits, ecnelises, hiraditya.
Herald added a project: LLVM.
laytonio requested review of this revision.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D92246
Files:
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -2707,36 +2707,18 @@
return SDValue();
}
-static SDValue flipBoolean(SDValue V, const SDLoc &DL,
- SelectionDAG &DAG, const TargetLowering &TLI) {
- EVT VT = V.getValueType();
-
- SDValue Cst;
- switch (TLI.getBooleanContents(VT)) {
- case TargetLowering::ZeroOrOneBooleanContent:
- case TargetLowering::UndefinedBooleanContent:
- Cst = DAG.getConstant(1, DL, VT);
- break;
- case TargetLowering::ZeroOrNegativeOneBooleanContent:
- Cst = DAG.getAllOnesConstant(DL, VT);
- break;
- }
-
- return DAG.getNode(ISD::XOR, DL, VT, V, Cst);
-}
-
/**
* Flips a boolean if it is cheaper to compute. If the Force parameters is set,
* then the flip also occurs if computing the inverse is the same cost.
* This function returns an empty SDValue in case it cannot flip the boolean
* without increasing the cost of the computation. If you want to flip a boolean
- * no matter what, use flipBoolean.
+ * no matter what, use DAG.getLogicalNOT.
*/
static SDValue extractBooleanFlip(SDValue V, SelectionDAG &DAG,
const TargetLowering &TLI,
bool Force) {
if (Force && isa<ConstantSDNode>(V))
- return flipBoolean(V, SDLoc(V), DAG, TLI);
+ return DAG.getLogicalNOT(SDLoc(V), V, V.getValueType());
if (V.getOpcode() != ISD::XOR)
return SDValue();
@@ -2763,7 +2745,7 @@
if (IsFlip)
return V.getOperand(0);
if (Force)
- return flipBoolean(V, SDLoc(V), DAG, TLI);
+ return DAG.getLogicalNOT(SDLoc(V), V, V.getValueType());
return SDValue();
}
@@ -2800,8 +2782,9 @@
if (isBitwiseNot(N0) && isOneOrOneSplat(N1)) {
SDValue Sub = DAG.getNode(ISD::USUBO, DL, N->getVTList(),
DAG.getConstant(0, DL, VT), N0.getOperand(0));
- return CombineTo(N, Sub,
- flipBoolean(Sub.getValue(1), DL, DAG, TLI));
+ SDValue Carry = Sub.getValue(1);
+ SDValue NotCarry = DAG.getLogicalNOT(DL, Carry, Carry.getValueType());
+ return CombineTo(N, Sub, NotCarry);
}
if (SDValue Combined = visitUADDOLike(N0, N1, N))
@@ -3103,8 +3086,9 @@
SDLoc DL(N);
SDValue Sub = DAG.getNode(ISD::SUBCARRY, DL, N->getVTList(), N1,
N0.getOperand(0), NotC);
- return CombineTo(N, Sub,
- flipBoolean(Sub.getValue(1), DL, DAG, TLI));
+ SDValue Carry = Sub.getValue(1);
+ SDValue NotCarry = DAG.getLogicalNOT(DL, Carry, Carry.getValueType());
+ return CombineTo(N, Sub, NotCarry);
}
// Iff the flag result is dead:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92246.308107.patch
Type: text/x-patch
Size: 2842 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201127/04d1d340/attachment.bin>
More information about the llvm-commits
mailing list