[llvm] 7b5a5be - [DAG] visitSUB/visitSUBO - move getAsNonOpaqueConstant into the if() where its used. NFC.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 21 02:19:32 PDT 2024


Author: Simon Pilgrim
Date: 2024-03-21T09:19:12Z
New Revision: 7b5a5be2a7216906c20f9bcac2209ea3502a7a73

URL: https://github.com/llvm/llvm-project/commit/7b5a5be2a7216906c20f9bcac2209ea3502a7a73
DIFF: https://github.com/llvm/llvm-project/commit/7b5a5be2a7216906c20f9bcac2209ea3502a7a73.diff

LOG: [DAG] visitSUB/visitSUBO - move getAsNonOpaqueConstant into the if() where its used. NFC.

Noticed while beginning some cleanup for moving to pattern matchers

Added: 
    

Modified: 
    llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index f199625bf67ad3..1884722198829f 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -3725,13 +3725,10 @@ SDValue DAGCombiner::visitSUB(SDNode *N) {
   if (SDValue NewSel = foldBinOpIntoSelect(N))
     return NewSel;
 
-  ConstantSDNode *N1C = getAsNonOpaqueConstant(N1);
-
   // fold (sub x, c) -> (add x, -c)
-  if (N1C) {
+  if (ConstantSDNode *N1C = getAsNonOpaqueConstant(N1))
     return DAG.getNode(ISD::ADD, DL, VT, N0,
                        DAG.getConstant(-N1C->getAPIntValue(), DL, VT));
-  }
 
   if (isNullOrNullSplat(N0)) {
     unsigned BitWidth = VT.getScalarSizeInBits();
@@ -4131,13 +4128,11 @@ SDValue DAGCombiner::visitSUBO(SDNode *N) {
     return CombineTo(N, DAG.getConstant(0, DL, VT),
                      DAG.getConstant(0, DL, CarryVT));
 
-  ConstantSDNode *N1C = getAsNonOpaqueConstant(N1);
-
   // fold (subox, c) -> (addo x, -c)
-  if (IsSigned && N1C && !N1C->isMinSignedValue()) {
-    return DAG.getNode(ISD::SADDO, DL, N->getVTList(), N0,
-                       DAG.getConstant(-N1C->getAPIntValue(), DL, VT));
-  }
+  if (ConstantSDNode *N1C = getAsNonOpaqueConstant(N1))
+    if (IsSigned && !N1C->isMinSignedValue())
+      return DAG.getNode(ISD::SADDO, DL, N->getVTList(), N0,
+                         DAG.getConstant(-N1C->getAPIntValue(), DL, VT));
 
   // fold (subo x, 0) -> x + no borrow
   if (isNullOrNullSplat(N1))


        


More information about the llvm-commits mailing list