Skip to content

20260515 cse dominance trick#485

Open
prozacchiwawa wants to merge 14 commits into
mainfrom
20260515-cse-dominance-trick
Open

20260515 cse dominance trick#485
prozacchiwawa wants to merge 14 commits into
mainfrom
20260515-cse-dominance-trick

Conversation

@prozacchiwawa

@prozacchiwawa prozacchiwawa commented May 18, 2026

Copy link
Copy Markdown
Contributor

Note

Medium Risk
Changes optimizer semantics for conditional CSE hoisting; incorrect dominance logic could alter compiled program behavior, though behavior is gated by dialect and legacy paths are preserved.

Overview
Fixes common subexpression elimination when repeated expressions sit inside nested if/i branches: the optimizer could treat a subexpression as safe to hoist even when a deeper conditional reused it without true dominance.

Adds dialect flag cse_dominance on AcceptedDialect (off for all *standard-cl-* includes; compile_module turns it on whenever stepping is set, alongside existing module dialect bumps). cse_is_covering now takes CompilerOpts and, when the flag is enabled, recursively rejects coverage if any downstream condition overlapping the CSE is not itself covered; the prior path-overlap check remains when the flag is false.

CSE entry points (cse_optimize_bodyform, cse_classify_by_conditions, Strategy23 frontend) thread opts through. Regression coverage: resources/tests/cse-complex-4.clsp and test_cse_tricky_2; existing tests pin cse_dominance: false where they assert legacy behavior.

Reviewed by Cursor Bugbot for commit 320cb6a. Bugbot is set up for automated code reviews on this repo. Configure here.

@prozacchiwawa prozacchiwawa marked this pull request as ready for review May 18, 2026 16:15
@prozacchiwawa prozacchiwawa marked this pull request as draft May 18, 2026 16:15

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 431119e. Configure here.

Comment thread src/compiler/optimize/cse.rs
@prozacchiwawa prozacchiwawa marked this pull request as ready for review May 18, 2026 18:20
@prozacchiwawa prozacchiwawa changed the base branch from 20260514-tricky-cse-assign to main June 30, 2026 17:26
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.

1 participant