Skip to content

Conversation

@sumleo
Copy link
Contributor

@sumleo sumleo commented Feb 10, 2026

Summary

  • Fix swapped mergeIf arguments in doVisitIf when an if has no else branch
  • Add GTest to verify phi node values are correctly associated with true/false conditions

Fixes #8273.

In the no-else case, mergeIf(initialState, afterIfTrueState, ...) incorrectly paired the initial state (before the if body ran) with the ifTrue condition and the after-if-true state with the ifFalse condition. The fix swaps the arguments to mergeIf(afterIfTrueState, initialState, ...), matching the convention used in the if-with-else case.

Test plan

  • Added DataflowTest.IfNoElseMergeOrder GTest that builds a dataflow graph for an if-no-else function and verifies the phi node selects the correct values for each branch
  • Verified the test fails before the fix (values 10 and 42 are swapped) and passes after
  • All 306 existing unit tests continue to pass

…mbly#8273)

In doVisitIf, when an if has no else branch, the two state arguments
passed to mergeIf were in the wrong order. This caused the phi node
to pair the "condition true" value with the initial state and the
"condition false" value with the after-if-true state.
disjoint_sets.cpp
glbs.cpp
interpreter.cpp
ir-bug-verification.cpp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this references a file that's not part of the commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mergeIf arguments are swapped in the no-else case in Dataflow IR

2 participants