-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8356813: Improve Mod(I|L)Node::Value #25254
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
base: master
Are you sure you want to change the base?
Conversation
👋 Welcome back hgreule! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
Can we return Besides, #17508 should be merged right after JDK-25 folk, do you want to wait for it first? |
That should work too and might be more intuitive. I assume there also isn't much benefit in constant-folding users of the mod if the mod is known to fail (which seems to be the only benefit of not returning TOP?).
We can wait if it makes sense to do the unsigned variants here too, but I'm also fine with doing it separately. |
This change improves the precision of the
Mod(I|L)Node::Value()
functions.I reordered the structure a bit. First, we handle constants, afterwards, we handle ranges. The bottom checks seem to be excessive (
Type::BOTTOM
is covered by usingisa_(int|long)()
, the local bottom is just the full range). Given we can even give reasonable bounds if only one input has any bounds, we don't want to return early.The changes after that are commented. Please let me know if the explanations are good, or if you have any suggestions.
Monotonicity
Before, a 0 divisor resulted in
Type(Int|Long)::POS
. Initially I wanted to keep it this way, but that violates monotonicity during PhaseCCP. As an example, if we see a 0 divisor first and a 3 afterwards, we might try to go from>=0
to-2..2
, but the meet of these would be>=-2
rather than-2..2
. UsingType(Int|Long)::ZERO
instead (zero is always in the resulting value if we cover a range).Testing
I added tests for cases around the relevant bounds. I also ran tier1, tier2, and tier3 but didn't see any related failures after addressing the monotonicity problem described above (I'm having a few unrelated failures on my system currently, so separate testing would be appreciated in case I missed something).
Please review and let me know what you think.
Other
The
UMod(I|L)Node
s were adjusted to be more in line with its signed variants. This change diverges them again, but similar improvements could be made after #17508.During experimenting with these changes, I stumbled upon a few things that aren't directly related to this change, but might be worth to further look into:
Mod(I|L)Node
with more but less expensive nodes in::Ideal()
. Type analysis for these nodes combined is less precise, means we miss potential cases were this would help e.g., removing range checks. Would it make sense to delay the replacement?char
. I noticed that method parameters of sub-int integer types all fall back toTypeInt::INT
. This seems to be an intentional change of 200784d. The bug report is private, so I can't really judge if that part is necessary, but it seems odd.Progress
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/25254/head:pull/25254
$ git checkout pull/25254
Update a local copy of the PR:
$ git checkout pull/25254
$ git pull https://git.openjdk.org/jdk.git pull/25254/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 25254
View PR using the GUI difftool:
$ git pr show -t 25254
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/25254.diff
Using Webrev
Link to Webrev Comment