[flang-commits] [flang] [llvm] [VPlan] Expand WidenInt inductions with nuw/nsw (PR #163538)

Florian Hahn via flang-commits flang-commits at lists.llvm.org
Fri Oct 24 03:24:55 PDT 2025


================
@@ -7549,16 +7549,20 @@ createWidenInductionRecipes(PHINode *Phi, Instruction *PhiOrTrunc,
   assert(SE.isLoopInvariant(IndDesc.getStep(), &OrigLoop) &&
          "step must be loop invariant");
 
+  // It is always safe to copy over the NoWrap and FastMath flags. In
+  // particular, when folding tail by masking, the masked-off lanes are never
+  // executed, so it is safe.
----------------
fhahn wrote:

To clarify, the lanes are still excecuted, but they are not used, as they are masked off.

I am not sure if that holds in all cases, one case to double check is: we have a wide canonical induction that has is used to compute the header mask. In that case, none of its lanes get masked. I think the current runtime checks checks ensure that the it won't unsigned-wrap, but it may sign-wrap, poisoning if it has NSW flags.

This is not an issue for floating point inductions.

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


More information about the flang-commits mailing list