[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:10:09 PDT 2026


================
@@ -1282,6 +1286,72 @@ bool VectorCombine::scalarizeVPIntrinsic(Instruction &I) {
   return true;
 }
 
+Value *VectorCombine::createUnaryOp(Instruction::UnaryOps Opcode,
+                                    Value *Operand, Instruction &OldI) {
+  switch (Opcode) {
+  case Instruction::FNeg:
+    return Builder.CreateFNegFMF(Operand, &OldI,
+                                 OldI.getName() + ".scalar.fneg");
+  case Instruction::UnaryOpsEnd:
+    llvm_unreachable("Invalid unary opcode");
+  }
+  llvm_unreachable("Invalid unary opcode");
+}
+
+Value *VectorCombine::createBinaryOp(Instruction::BinaryOps Opcode, Value *LHS,
----------------
jackhong12 wrote:

I added more lit cases under llvm/test/Transforms/VectorCombine/binop-scalarize.ll. It covers all binary opcode here.

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


More information about the llvm-commits mailing list