[llvm] [VPlan] Do not reuse scalar NSW on reconstructed widened induction mul/add (PR #229350)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 7 03:46:40 PDT 2026
================
@@ -267,9 +267,19 @@ expandVPWidenIntOrFpInduction(VPWidenIntOrFpInductionRecipe *WidenIVR) {
Instruction::BinaryOps AddOp;
Instruction::BinaryOps MulOp;
VPIRFlags Flags = *WidenIVR;
+ VPIRFlags AddFlags = Flags;
+ VPIRFlags MulFlags = Flags;
if (ID.getKind() == InductionDescriptor::IK_IntInduction) {
AddOp = Instruction::Add;
MulOp = Instruction::Mul;
+ // Reconstructed initial addition can preserve NUW from the scalar
+ // recurrence since unsigned addition is monotonic, but cannot preserve
+ // NSW as intermediate vector lane offsets (e.g., lane * step) may wrap
+ // signed bounds even if scalar additions do not. Reconstructed
+ // multiplications cannot preserve NSW or NUW from scalar additions.
+ AddFlags = VPIRFlags(VPIRFlags::WrapFlagsTy(
+ Flags.getNoWrapFlagsOrNone().HasNUW, /*HasNSW=*/false));
----------------
artagnon wrote:
```suggestion
AddFlags = VPIRFlags::WrapFlagsTy(
Flags.getNoWrapFlagsOrNone().HasNUW, /*HasNSW=*/false);
```
I think it will automatically construct a VPIRFlags?
https://github.com/llvm/llvm-project/pull/229350
More information about the llvm-commits
mailing list