[llvm] [VPlan] Model first memory runtime checks as VPlan recipes. (PR #221483)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 23 06:50:28 PDT 2026


================
@@ -1541,6 +1541,14 @@ static VPSingleDefRecipe *combineRecipe(VPlan &Plan, VPSingleDefRecipe *Def) {
         {X, Plan.getConstantInt(APC->getBitWidth(), APC->exactLogBase2())},
         *cast<VPRecipeWithIRFlags>(Def), Def->getDebugLoc());
 
+  // (X >> C) << C -> X & (-1 << C).
+  if (CanCreateNewRecipe &&
+      match(Def, m_Shl(m_LShr(m_VPValue(X), m_VPValue(Y, m_APInt(APC))),
+                       m_Deferred(Y))))
+    return Builder.createAnd(
+        X, Plan.getConstantInt(APInt::getAllOnes(APC->getBitWidth()) << *APC),
+        Def->getDebugLoc());
----------------
fhahn wrote:

Currently we would not get a diff; we could add a test that contains this pattern in IR, but the fold should be a no-op in the default pipeline, as instcombine should already simplified the incoming IR. With this patch, we generate the pattern (originally I had it as fold in the expander directly)

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


More information about the llvm-commits mailing list