[VPlan] Remove redundant x && (y && x) -> x && y combine (#213219)

It can be subsumed by making the combine above commutative. In theory
this isn't NFC as it changes the order, in practice it doesn't make a
difference.
This commit is contained in:
Luke Lau 2026-07-31 18:55:33 +08:00 committed by GitHub
parent 136347be7a
commit 8db13de265
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 10 deletions

View file

@ -199,6 +199,11 @@ inline bind_const_int m_ConstantInt(uint64_t &C) { return C; }
/// Match a VPValue, capturing it if we match.
inline match_bind<VPValue> m_VPValue(VPValue *&V) { return V; }
/// Match against the nested pattern, and capture the value if we match.
template <typename Op_t> inline auto m_VPValue(VPValue *&V, const Op_t &Op) {
return m_CombineAnd(Op, m_VPValue(V));
}
/// Match a VPIRValue.
inline match_bind<VPIRValue> m_VPIRValue(VPIRValue *&V) { return V; }

View file

@ -1188,16 +1188,10 @@ static bool simplifyLogicalRecipe(VPSingleDefRecipe *Def, VPBuilder &Builder,
}
// x && (x && y) -> x && y
if (match(Def, m_LogicalAnd(m_VPValue(X),
m_LogicalAnd(m_Deferred(X), m_VPValue())))) {
Def->replaceAllUsesWith(Def->getOperand(1));
return true;
}
// x && (y && x) -> x && y
if (match(Def, m_LogicalAnd(m_VPValue(X),
m_LogicalAnd(m_VPValue(Y), m_Deferred(X))))) {
Def->replaceAllUsesWith(Builder.createLogicalAnd(X, Y));
if (match(Def, m_c_LogicalAnd(m_VPValue(X),
m_VPValue(Z, m_c_LogicalAnd(m_Deferred(X),
m_VPValue()))))) {
Def->replaceAllUsesWith(Z);
return true;
}