fix: don't re-invert a shared 'if' condition in a duplicated block#2907
Open
obus-globus wants to merge 1 commit into
Open
fix: don't re-invert a shared 'if' condition in a duplicated block#2907obus-globus wants to merge 1 commit into
obus-globus wants to merge 1 commit into
Conversation
obus-globus
force-pushed
the
fix/duplicated-block-invert
branch
from
July 4, 2026 02:59
355cf98 to
b27565a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NOTE: This is what one may call "AI slop". Feel free to close this PR if it's not up to your quality standards or even if you just aren't interested in reviewing it. I use these changes downstream on an APK and thought I might as well make a PR offering to upstream them, as your CONTRIBUTING.md doesn't say anything discouraging this.
Description
Demonstrated on the java/class input path. A condition that heads a block belonging to more than one region is inverted one extra time, flipping its first operand. For
the inner
(x || y)decompiled as(!x || y): the first operand picked up a spurious negation.IfRegionMaker.processinverts a simple condition in place:IfInfo.invert(viaIfCondition.invert) callsCompare.invert, which mutates the block's sharedIfNodein place. The(x || y)block heads a merged short-circuit condition and is also reached from two predecessors (AFlag.DUPLICATED), so it is processed as a region head more than once. TheDONT_INVERTguard that prevents a second in-place inversion was only set on the simple-invert path, not when the condition was built bymergeNestedIfNodes, so the later standalone pass inverted the already-built condition again and flipped its first operand.Set
AFlag.DONT_INVERTafter both the merge and the simple-invert branches, so a shared block's condition is inverted at most once regardless of how it was built.Includes an integration test.