[llvm] r218735 - [InstCombine] Fix for assert build failures caused by r218721

Gerolf Hoflehner ghoflehner at apple.com
Tue Sep 30 20:24:40 PDT 2014


Author: ghoflehner
Date: Tue Sep 30 22:24:39 2014
New Revision: 218735

URL: http://llvm.org/viewvc/llvm-project?rev=218735&view=rev
Log:
[InstCombine] Fix for assert build failures caused by r218721

The icmp-select-icmp optimization made the implicit assumption
that the select-icmp instructions are in the same block and asserted on it.
The fix explicitly checks for that condition and conservatively suppresses
the optimization when it is violated.


Modified:
    llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp

Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=218735&r1=218734&r2=218735&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Tue Sep 30 22:24:39 2014
@@ -2442,7 +2442,7 @@ static bool swapMayExposeCSEOpportunitie
 bool InstCombiner::dominatesAllUses(const Instruction *DI,
                                     const Instruction *UI,
                                     const BasicBlock *DB) const {
-  assert(DI && DI->getParent() == UI->getParent() &&
+  assert(DI && UI && DI->getParent() == UI->getParent() &&
          "definition and use must be in the same block");
   // DominatorTree available?
   if (!DT)
@@ -2468,6 +2468,12 @@ static bool isChainSelectCmpBranch(const
   auto *IC = dyn_cast<ICmpInst>(BI->getCondition());
   if (!IC || (IC->getOperand(0) != SI && IC->getOperand(1) != SI))
     return false;
+  // FIXME: Conservatively suppress the optimization when the IC
+  // has a parent different from SI (including no parent). Otherwise
+  // the assertion in dominatesAllUses() fires and causes a build failure.
+  // Make the optimization safe w/o this condition.
+  if (SI->getParent() != IC->getParent())
+    return false;
   return true;
 }
 





More information about the llvm-commits mailing list