[InstCombine] Remove OneUse clause from ((A+B)+B) → A+2*B
#80705
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.
This patch removes the
m_OneUse
check that was being done for the following patterns:(A + RHS) + RHS --> A + (RHS << 1)
LHS + (A + LHS) --> A + (LHS << 1)
This may increase the instruction count if (A + RHS) or (A + LHS) are used more than once but will usually help with LICM later on if A is an induction variable.
This is exemplified here: https://godbolt.org/z/q94vbf5e9 - the first instruction of the second iteration ([1,0]) can start much earlier on with the patch, allowing for significantly higher IPC.
I've benchmarked this with RAJAPerf on a Grace system and see an overall performance uplift of 2% across the whole benchmark which comes mainly from ~45% uplifts in three kernels. Worst I saw was a 1.2% slowdown on a single kernel which I look into later.
Please let me know if I should move this elsewhere!