DFG peephole: Only push SEL through COND when SEL is the only sink. (#6071)

This avoids potential O(n) logic duplication where 'n' is the fanout of
the COND node.

Fixes #6064.
This commit is contained in:
Geza Lore 2025-06-08 11:12:39 +01:00 committed by GitHub
parent 5b2dc52681
commit a6bae7f196
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 1 deletions

View File

@ -844,7 +844,8 @@ class V3DfgPeephole final : public DfgVisitor {
// Sel from Cond
if (DfgCond* const condp = fromp->cast<DfgCond>()) {
// If at least one of the branches are a constant, push the select past the cond
if (condp->thenp()->is<DfgConst>() || condp->elsep()->is<DfgConst>()) {
if (!condp->hasMultipleSinks()
&& (condp->thenp()->is<DfgConst>() || condp->elsep()->is<DfgConst>())) {
APPLYING(PUSH_SEL_THROUGH_COND) {
// The new 'then' vertex
DfgSel* const newThenp = make<DfgSel>(vtxp, condp->thenp(), lsb);