InstCombine: fix sinking of convergent calls
authorFiona Glaser <escha@apple.com>
Tue, 3 Nov 2015 22:23:39 +0000 (22:23 +0000)
committerFiona Glaser <escha@apple.com>
Tue, 3 Nov 2015 22:23:39 +0000 (22:23 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251991 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/InstCombine/InstructionCombining.cpp

index b51ec291f9134bc6556e5d3eff8ab8138450cdf4..ac535f97bb1c6f15edfeba800fe36160eda22d15 100644 (file)
@@ -2694,6 +2694,12 @@ static bool TryToSinkInstruction(Instruction *I, BasicBlock *DestBlock) {
         &DestBlock->getParent()->getEntryBlock())
     return false;
 
+  // Do not sink convergent call instructions.
+  if (auto *CI = dyn_cast<CallInst>(I)) {
+    if (CI->isConvergent())
+      return false;
+  }
+
   // We can only sink load instructions if there is nothing between the load and
   // the end of block that could change the value.
   if (I->mayReadFromMemory()) {