RFR: 8282365: Consolidate and improve division by constant idealizations [v45]

Quan Anh Mai qamai at openjdk.org
Sat Jan 20 12:17:04 UTC 2024


On Sat, 20 Jan 2024 12:12:47 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:

>> I think it makes it more uniform with the other case and since we are writing it as `rc = 2 * rc - d`, expanding it to `rc + rc - d` seems more natural. Note that the type is unsigned so overflow behaviour is not undefined.
>
> The purpose of the `//` comment is to make it even more clear that `rc -= d - rc` computes `rc = 2 * rc - d`. But in fact, the expansion `rc = rc - (d - rc)` is already clear enough, IMO.
> 
> Sure, the behavior with the underflow is specified: that's what I mean by "benign" in my previous comment. Yet, one must reason longer to be convinced that the underflow is harmless.
> 
> Of course, this is a subjective matter about clarity of the code. Everybody has their own opinion about ;-)

Yes I agree, so I just made it simple and straightforward.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/9947#discussion_r1460406215


More information about the hotspot-compiler-dev mailing list