Skip to content

Distinguish Definitions from Usages in Variable Resolver#219

Merged
rcosta358 merged 1 commit into
function-invocation-simplificationfrom
distinguish-definitions-usages
May 13, 2026
Merged

Distinguish Definitions from Usages in Variable Resolver#219
rcosta358 merged 1 commit into
function-invocation-simplificationfrom
distinguish-definitions-usages

Conversation

@rcosta358
Copy link
Copy Markdown
Collaborator

@rcosta358 rcosta358 commented May 12, 2026

Description

This PR fixes a problem in the simplification where value propagation could be skipped for expressions like x == 1 && x == 2. The resolver treated any equality involving x and a literal as the definition of x, even when only one of those equalities was the actual definition being propagated.

Now the resolver tracks the value that defined the substitution and uses it to distinguish the defining equality from later usages. For a direct contradiction like x == 1 && x == 2, either value can be picked for propagation: both expose the contradiction and fold to false.

Example

Before

mode⁷⁰ == 1 &&
(mode⁷⁰ == 2 ? compressionExplicit(param⁷¹) : startCompression(param⁷¹)) &&
state1(param⁷¹) == state1(param⁶⁹) &&
startTiling(param⁶⁹) &&
startCompression(param⁶⁹)

After

startCompression(param⁷¹) &&
state1(param⁷¹) == state1(param⁶⁹) &&
startTiling(param⁶⁹) &&
startCompression(param⁶⁹)

Related Issue

None.

Type of change

  • Bug fix
  • New feature
  • Documentation update
  • Code refactoring

Checklist

  • Added/updated tests in ExpressionSimplifierTest and VariableResolverTest
  • mvn test passes locally
  • Updated docs/README if behavior or API changed

@rcosta358 rcosta358 requested a review from CatarinaGamboa May 12, 2026 16:19
@rcosta358 rcosta358 self-assigned this May 12, 2026
@rcosta358 rcosta358 added bug Something isn't working simplification Related to the simplification of expressions labels May 12, 2026
@rcosta358 rcosta358 changed the title Distinguish Definitions from Usages Distinguish Definitions from Usages in Variable Resolver May 12, 2026
Copy link
Copy Markdown
Collaborator

@CatarinaGamboa CatarinaGamboa left a comment

Choose a reason for hiding this comment

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

Awesome! We still need something similar now to deal with final fields/enums right?

@rcosta358
Copy link
Copy Markdown
Collaborator Author

Yeah we need to handle enums in the simplification process.
Will do it in a separate PR.

@rcosta358 rcosta358 merged commit cea20a2 into function-invocation-simplification May 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working simplification Related to the simplification of expressions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants