[Opt] Simplify multiplying/dividing POT #2332
Merged
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.
Related issue = #944 #656 #2177
This PR may help with some optimizations after #2327 is merged. When we want to access a leaf (place) SNode and (the same address of) its parent or some ancestor, simple optimizations such as CSE can remove the duplicated part of the access paths after lower_access when nonconsecutive indices are used (now). However, when consecutive indices are used, we may have some code like this:
And we want the common part of
block[i / 8]
anda[i]
is reused in the two accesses. After expanding theBitExtractStmt
, the former one will be(i / 8) & 63
and the latter one will be(i >> 3) & 63
. This PR replacesi / 8
withi >> 3
, and further replaces(a >> b) >> c
witha >> (b + c)
when bothb
andc
are constants, so that CSE will be able to remove the duplicated access paths after lower_access.This PR also enables constant folding for unsigned data types.
[Click here for the format server]