[llvm] [VPlan] Avoid getting flags from UV in partial-red (PR #190214)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 7 09:50:36 PDT 2026


================
@@ -5992,11 +5995,9 @@ static void transformToPartialReduction(const VPPartialReductionChain &Chain,
     VPBuilder Builder(WidenRecipe);
     Type *ElemTy = TypeInfo.inferScalarType(BinOp);
     auto *Zero = Plan.getZero(ElemTy);
-    VPIRFlags Flags = WidenRecipe->getUnderlyingInstr()
-                          ? VPIRFlags(*WidenRecipe->getUnderlyingInstr())
-                          : VPIRFlags();
-    auto *NegRecipe = new VPWidenRecipe(Instruction::Sub, {Zero, BinOp}, Flags,
-                                        VPIRMetadata(), DebugLoc::getUnknown());
+    auto *NegRecipe =
+        new VPWidenRecipe(Instruction::Sub, {Zero, BinOp}, *WidenRecipe,
----------------
fhahn wrote:

I think this transforms `sub %a, %b` - > `add %a (sub 0, %b)`. In that case, preserving `nsw` would be incorrect:  https://alive2.llvm.org/ce/z/6rvxFY

But what's surprising is that the `nsw` flag is on the underlying instr but not the WidenRecipe itself. Did we drop it somewhere? Better explicity not use any flags?

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


More information about the llvm-commits mailing list