Skip to content

Commit 7b5a5be

Browse files
committed
[DAG] visitSUB/visitSUBO - move getAsNonOpaqueConstant into the if() where its used. NFC.
Noticed while beginning some cleanup for moving to pattern matchers
1 parent 9fb85b0 commit 7b5a5be

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3725,13 +3725,10 @@ SDValue DAGCombiner::visitSUB(SDNode *N) {
37253725
if (SDValue NewSel = foldBinOpIntoSelect(N))
37263726
return NewSel;
37273727

3728-
ConstantSDNode *N1C = getAsNonOpaqueConstant(N1);
3729-
37303728
// fold (sub x, c) -> (add x, -c)
3731-
if (N1C) {
3729+
if (ConstantSDNode *N1C = getAsNonOpaqueConstant(N1))
37323730
return DAG.getNode(ISD::ADD, DL, VT, N0,
37333731
DAG.getConstant(-N1C->getAPIntValue(), DL, VT));
3734-
}
37353732

37363733
if (isNullOrNullSplat(N0)) {
37373734
unsigned BitWidth = VT.getScalarSizeInBits();
@@ -4131,13 +4128,11 @@ SDValue DAGCombiner::visitSUBO(SDNode *N) {
41314128
return CombineTo(N, DAG.getConstant(0, DL, VT),
41324129
DAG.getConstant(0, DL, CarryVT));
41334130

4134-
ConstantSDNode *N1C = getAsNonOpaqueConstant(N1);
4135-
41364131
// fold (subox, c) -> (addo x, -c)
4137-
if (IsSigned && N1C && !N1C->isMinSignedValue()) {
4138-
return DAG.getNode(ISD::SADDO, DL, N->getVTList(), N0,
4139-
DAG.getConstant(-N1C->getAPIntValue(), DL, VT));
4140-
}
4132+
if (ConstantSDNode *N1C = getAsNonOpaqueConstant(N1))
4133+
if (IsSigned && !N1C->isMinSignedValue())
4134+
return DAG.getNode(ISD::SADDO, DL, N->getVTList(), N0,
4135+
DAG.getConstant(-N1C->getAPIntValue(), DL, VT));
41414136

41424137
// fold (subo x, 0) -> x + no borrow
41434138
if (isNullOrNullSplat(N1))

0 commit comments

Comments
 (0)