[llvm] [VectorCombine] Only copy IR flags for newly created instructions (PR #193271)

Jack Huang via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 22 21:11:45 PDT 2026


================
@@ -1443,10 +1443,21 @@ bool VectorCombine::scalarizeOpOrCmp(Instruction &I) {
 
   Scalar->setName(I.getName() + ".scalar");
 
-  // All IR flags are safe to back-propagate. There is no potential for extra
-  // poison to be created by the scalar instruction.
-  if (auto *ScalarInst = dyn_cast<Instruction>(Scalar))
-    ScalarInst->copyIRFlags(&I);
+  if (auto *ScalarInst = dyn_cast<Instruction>(Scalar)) {
+    bool IsFoldOp = false;
+    for (auto Op : ScalarOps) {
+      if (Op == ScalarInst) {
+        IsFoldOp = true;
+        break;
+      }
+    }
+
+    // If ScalarInst is not one of the existing operands, it must be newly
----------------
jackhong12 wrote:

Pass the flags during IR creation.

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


More information about the llvm-commits mailing list