Skip to content

Conversation

jakobbotsch
Copy link
Member

@jakobbotsch jakobbotsch commented Jul 18, 2024

This adds a new optimization in the IV opts phase that removes unused primary IVs from loops. Liveness is unable to remove IVs since they are self-referential, and strength reduction can sometimes leave old IVs unused (normally they would get removed by the downwards loop optimization, but only if the old primary IV was used in a loop test).

Removes code in the downwards loop optimization to remove statements; this will be handled by this new pass.

Also factors IV widening into its own function.

This adds a new optimization in the IV opts phase that removes unused
primary IVs from loops. Liveness is unable to remove IVs since they are
self-referential, and strength reduction can sometimes leave old IVs
unused (normally they would get removed by the downwards loop
optimization, but only if the old primary IV was used in a loop test).

Removes code in the downwards loop optimization to remove statements;
this will be handled by this new phase.

Also factors IV widening into its own function.
@ghost ghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jul 18, 2024
Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

@jakobbotsch jakobbotsch marked this pull request as ready for review July 18, 2024 21:34
@jakobbotsch
Copy link
Member Author

cc @dotnet/jit-contrib PTAL @AndyAyersMS

Diffs, Diffs with strength reduction enabled. The difference isn't that big, so doesn't seem like strength reduction was creating these cases often. Some minor TP regressions.

@jakobbotsch jakobbotsch requested a review from AndyAyersMS July 18, 2024 22:16
@jakobbotsch jakobbotsch changed the title JIT: Add a phase to remove unused primary IVs JIT: Add a pass to remove unused primary IVs Jul 18, 2024
Comment on lines +765 to +768
bool Compiler::optWidenIVs(ScalarEvolutionContext& scevContext,
FlowGraphNaturalLoop* loop,
LoopLocalOccurrences* loopLocals)
{
Copy link
Member Author

Choose a reason for hiding this comment

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

This is just factoring IV widening into its own function... the new pass is down below.

@jakobbotsch jakobbotsch merged commit ae4bffa into dotnet:main Jul 19, 2024
@jakobbotsch jakobbotsch deleted the remove-ivs-pass branch July 19, 2024 07:51
@github-actions github-actions bot locked and limited conversation to collaborators Aug 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants