[llvm] [VectorCombine] Fix trunc generated between PHINodes (PR #108228)

Igor Kirillov via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 12 07:20:10 PDT 2024


================
@@ -2652,8 +2652,12 @@ bool VectorCombine::shrinkType(llvm::Instruction &I) {
     return false;
 
   Value *Op0 = ZExted;
-  if (auto *OI = dyn_cast<Instruction>(OtherOperand))
-    Builder.SetInsertPoint(OI->getNextNode());
+  if (auto *OI = dyn_cast<Instruction>(OtherOperand)) {
+    if (isa<PHINode>(OI))
+      Builder.SetInsertPoint(OI->getParent()->getFirstInsertionPt());
+    else
+      Builder.SetInsertPoint(OI->getNextNode());
+  }
----------------
igogo-x86 wrote:

You are right. I think I was worried that trunc might get swept inside the loop but LICM follows not so long after VectorCombine

https://github.com/llvm/llvm-project/pull/108398

https://github.com/llvm/llvm-project/pull/108228


More information about the llvm-commits mailing list