[PATCH] D50247: [GuardWidening] Ignore guards with trivial conditions

Fedor Sergeev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 3 05:52:44 PDT 2018


fedor.sergeev added a comment.

LGTM bar some minor stylistic stuff.



================
Comment at: lib/Transforms/Scalar/GuardWidening.cpp:354
+  if (Cond == True || Cond == False)
+    return false;
+
----------------
Can we just check that it is constant? Booleans hardly get any values other than True/False...


================
Comment at: lib/Transforms/Scalar/GuardWidening.cpp:422
   widenGuard(BestSoFar, getCondition(GuardInst), InvertCondition);
-  auto NewGuardCondition = InvertCondition
-                               ? ConstantInt::getFalse(GuardInst->getContext())
-                               : ConstantInt::getTrue(GuardInst->getContext());
+  auto *NewGuardCondition = InvertCondition ? False : True;
   setCondition(GuardInst, NewGuardCondition);
----------------
Uh... that reads somewhat uneasy, as False/True values are way up and I first read them as just bools :)


https://reviews.llvm.org/D50247





More information about the llvm-commits mailing list