[llvm] [VPlan] Simplify vp.merge true, (or x, y), x -> vp.merge y, true, x (PR #135017)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 10 02:49:43 PDT 2025


================
@@ -1011,6 +1011,17 @@ static void simplifyRecipe(VPRecipeBase &R, VPTypeAnalysis &TypeInfo) {
       TypeInfo.inferScalarType(R.getOperand(1)) ==
           TypeInfo.inferScalarType(R.getVPSingleValue()))
     return R.getVPSingleValue()->replaceAllUsesWith(R.getOperand(1));
+
+  // For i1 vp.merges produced by AnyOf reductions:
+  // vp.merge true, (or x, y), x, evl -> vp.merge y, true, x, evl
+  if (match(&R, m_Intrinsic<Intrinsic::vp_merge>(
+                    m_True(), m_c_BinaryOr(m_VPValue(X), m_VPValue(Y)),
+                    m_Deferred(X), m_VPValue())) &&
----------------
lukel97 wrote:

Thanks for catching that, I see now that the commutative part won't make a difference because m_VPValue will always match.

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


More information about the llvm-commits mailing list