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

Craig Topper craig.topper at gmail.com
Mon May 25 02:37:45 PDT 2015


================
Comment at: lib/Transforms/InstCombine/InstCombineCasts.cpp:281
@@ -280,6 +280,3 @@
   // idiom where each element of the extended vector is either zero or all ones.
-  if (opc == Instruction::SExt && isa<CmpInst>(V) && Ty->isVectorTy())
-    return false;
-
-  return true;
+  return !(opc == Instruction::SExt && isa<CmpInst>(V) && Ty->isVectorTy());
 }
----------------
Push the negate through

================
Comment at: lib/Transforms/InstCombine/InstCombineCompares.cpp:2559
@@ -2558,5 +2558,3 @@
   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));
 }
----------------
Push the negate through.

================
Comment at: lib/Transforms/InstCombine/InstructionCombining.cpp:100
@@ -99,6 +99,3 @@
   // do allow things like i160 -> i64, but not i64 -> i160.
-  if (!FromLegal && !ToLegal && ToWidth > FromWidth)
-    return false;
-
-  return true;
+  return !(!FromLegal && !ToLegal && ToWidth > FromWidth);
 }
----------------
Push the negate through

================
Comment at: lib/Transforms/InstCombine/InstructionCombining.cpp:959
@@ -961,5 +958,3 @@
   // the indices.
-  if (GEP.hasAllZeroIndices() && !Src.hasAllZeroIndices() &&
-      !Src.hasOneUse())
-    return false;
-  return true;
+  return !(GEP.hasAllZeroIndices() && !Src.hasAllZeroIndices() &&
+      !Src.hasOneUse());
----------------
Push the negate through

http://reviews.llvm.org/D9989

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list