Skip to content

Avoid cloning invokes in strength reduction.#4107

Open
meheff wants to merge 1 commit intogoogle:mainfrom
xlsynth:meheff/2026-04-13-strength-red-invoke
Open

Avoid cloning invokes in strength reduction.#4107
meheff wants to merge 1 commit intogoogle:mainfrom
xlsynth:meheff/2026-04-13-strength-red-invoke

Conversation

@meheff
Copy link
Copy Markdown
Collaborator

@meheff meheff commented Apr 14, 2026

Strength reduction will sink operations into a select if the transformation can result in constant folding or dramatic simplification. This was previously guarded by OpIsSideEffecting. This change also prevents the transformation if the operation is an invoke as the invoked function may be side-effecting.

This change fixes inf-looping of the optimizer with FFI functions. Invokes were being transformed, but the old dead invokes were not being DCE'd because dce doesn't remove invokes because they may result in side-effects. This change causes the optimizer to treat invokes as potentially side-effecting more consistently.

Strength reduction will sink operations into a select if the transformation can result in constant folding or dramtic simplification. This was previously guarded by OpIsSideEffecting. This change also prevents the transformation if the operation is an inoke as the invoked function may be side-effecting.

This was resulting in inflooping of the optimizer with FFI functions. Invokes were being transformed, but the old dead invokes were not being DCE'd because dce doesn't remove invokes because they may result in side-effects. This change causes the optimizer to treat invokes as potentially side-effecting more consistently.
meheff added a commit to xlsynth/xlsynth that referenced this pull request Apr 14, 2026
meheff added a commit to xlsynth/xlsynth that referenced this pull request Apr 14, 2026
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