[PATCH] D9989: Refactor: Simplify boolean conditional return statements in lib/Transforms/InstCombine

Richard via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 24 09:56:58 PDT 2015


LegalizeAdulthood updated this revision to Diff 38306.
LegalizeAdulthood added a comment.

Update to latest


http://reviews.llvm.org/D9989

Files:
  lib/Transforms/InstCombine/InstCombineAddSub.cpp
  lib/Transforms/InstCombine/InstCombineCompares.cpp
  lib/Transforms/InstCombine/InstructionCombining.cpp

Index: lib/Transforms/InstCombine/InstructionCombining.cpp
===================================================================
--- lib/Transforms/InstCombine/InstructionCombining.cpp
+++ lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -991,10 +991,7 @@
   // If this GEP has only 0 indices, it is the same pointer as
   // Src. If Src is not a trivial GEP too, don't combine
   // the indices.
-  if (GEP.hasAllZeroIndices() && !Src.hasAllZeroIndices() &&
-      !Src.hasOneUse())
-    return false;
-  return true;
+  return !GEP.hasAllZeroIndices() || Src.hasAllZeroIndices() || Src.hasOneUse();
 }
 
 /// Return a value X such that Val = X * Scale, or null if none.
Index: lib/Transforms/InstCombine/InstCombineCompares.cpp
===================================================================
--- lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -2670,9 +2670,7 @@
   if (!BI || BI->getNumSuccessors() != 2)
     return false;
   auto *IC = dyn_cast<ICmpInst>(BI->getCondition());
-  if (!IC || (IC->getOperand(0) != SI && IC->getOperand(1) != SI))
-    return false;
-  return true;
+  return IC && (IC->getOperand(0) == SI || IC->getOperand(1) == SI);
 }
 
 ///
Index: lib/Transforms/InstCombine/InstCombineAddSub.cpp
===================================================================
--- lib/Transforms/InstCombine/InstCombineAddSub.cpp
+++ lib/Transforms/InstCombine/InstCombineAddSub.cpp
@@ -980,10 +980,7 @@
                  &CxtI);
   ComputeSignBit(RHS, RHSKnownNonNegative, RHSKnownNegative, /*Depth=*/0,
                  &CxtI);
-  if (LHSKnownNegative && RHSKnownNonNegative)
-    return true;
-
-  return false;
+  return LHSKnownNegative && RHSKnownNonNegative;
 }
 
 // Checks if any operand is negative and we can convert add to sub.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9989.38306.patch
Type: text/x-patch
Size: 1821 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151024/29c8bdad/attachment.bin>


More information about the llvm-commits mailing list