[PATCH] Refactor: Simplify boolean conditional return statements in llvm/lib/CodeGen

Matthias Braun matze at braunis.de
Tue May 26 10:15:34 PDT 2015


There's still two instances where you can push the negation to the leafs of the expression:


================
Comment at: lib/CodeGen/Analysis.cpp:364-365
@@ -363,7 +363,4 @@
   // extensions too.
-  if (BitsProvided < BitsRequired ||
-      (!AllowDifferingSizes && BitsProvided != BitsRequired))
-    return false;
-
-  return true;
+  return !(BitsProvided < BitsRequired ||
+           (!AllowDifferingSizes && BitsProvided != BitsRequired));
 }
----------------
return BitsProvided >= BitsRequired &&
       (AllowDifferingSizes || BitsProvided == BitsRequired);

================
Comment at: lib/CodeGen/CodeGenPrepare.cpp:2285
@@ -2287,5 +2284,3 @@
   static bool shouldExtOperand(const Instruction *Inst, int OpIdx) {
-    if (isa<SelectInst>(Inst) && OpIdx == 0)
-      return false;
-    return true;
+    return !(isa<SelectInst>(Inst) && OpIdx == 0);
   }
----------------
return !isa<SelectInst>(Inst) || OpIdx != 0;

http://reviews.llvm.org/D9970

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






More information about the llvm-commits mailing list