[llvm] [VPlan] Simplify BCast with only-first-lane used (PR #195444)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Mon May 11 08:58:42 PDT 2026
================
@@ -1704,6 +1704,11 @@ static void simplifyRecipe(VPSingleDefRecipe *Def, VPTypeAnalysis &TypeInfo) {
return;
}
+ if (match(Def, m_Broadcast(m_VPValue(X))))
----------------
david-arm wrote:
Oh, it's just a bit confusing then because it returns the result of `replaceUsesWithIf` which gives the impression that the result type is non-void. It might be clearer if you just did:
```
Def->replaceUsesWithIf(X, [Def](const VPUser &U, unsigned) {
return U.usesFirstLaneOnly(Def);
});
return void;
```
With regard to the potential "spaghetti code", we seem to have examples already in simplifyRecipe that do exactly the sort of "spaghetti" code you mentioned, e.g.
```
// x | 0 -> x
if (match(Def, m_c_BinaryOr(m_VPValue(X), m_ZeroInt())))
return Def->replaceAllUsesWith(X);
// x | !x -> AllOnes
if (match(Def, m_c_BinaryOr(m_VPValue(X), m_Not(m_Deferred(X)))))
return Def->replaceAllUsesWith(
Plan->getAllOnesValue(TypeInfo.inferScalarType(Def)));
```
I guess if this is the only instance of the type `match(Def, m_Broadcast(...` so far it should be fine, and can be extended in future.
https://github.com/llvm/llvm-project/pull/195444
More information about the llvm-commits
mailing list