[llvm] [VPlan] Fold safe divisors into VP intrinsics with EVL (PR #148828)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 16 03:21:45 PDT 2025
================
@@ -2176,6 +2176,52 @@ static VPRecipeBase *optimizeMaskToEVL(VPValue *HeaderMask,
.Default([&](VPRecipeBase *R) { return nullptr; });
}
+/// Try to optimize safe divisors away by converting their users to VP
+/// intrinsics:
+///
+/// udiv x, (vp.merge allones, y, 1, evl) -> vp.udiv x, y, allones, evl
+///
+/// Note the lanes past EVL will be changed from x to poison. This only works
+/// for the EVL-based IV and not any arbitrary EVL, because we know nothing
+/// will read the lanes past the EVL-based IV.
----------------
fhahn wrote:
Should we have an assert that all users of the op are also predicated?
>From the explanation, it's not entirely clear how this is related to EVL-based IV. Isn't the requirement that both the udiv and all its users use the same EVL?
https://github.com/llvm/llvm-project/pull/148828
More information about the llvm-commits
mailing list