[PATCH] D36975: [InstCombine] Fold branches with irrelevant conditions to a constant

David Majnemer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 21 14:36:13 PDT 2017


majnemer added inline comments.


================
Comment at: lib/Transforms/InstCombine/InstructionCombining.cpp:2263
   // transforms on the condition become more effective.
-  if (BI.isConditional() &&
-      BI.getSuccessor(0) == BI.getSuccessor(1) &&
-      !isa<UndefValue>(BI.getCondition())) {
-    BI.setCondition(UndefValue::get(BI.getCondition()->getType()));
+  if (BI.isConditional() && !isa<Constant>(BI.getCondition()) &&
+      BI.getSuccessor(0) == BI.getSuccessor(1)) {
----------------
I think we want !isa<ConstantInt> instead of Constant. The branch condition could be some crazy (icmp i32 (ptrtoint ... to i32), ...) and replacing it with false is more canonical.


https://reviews.llvm.org/D36975





More information about the llvm-commits mailing list