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

Quan Anh Mai qamai at openjdk.org
Wed Jan 31 17:32:42 UTC 2024


On Fri, 26 Jan 2024 17:19:01 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:

>> Quan Anh Mai has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   just be simple
>
> src/hotspot/share/opto/divconstants.cpp line 55:
> 
>> 53: //
>> 54: // ceil(x / d) = floor(x * c / m) + 1 for every integer x in [-N, 0)
>> 55: //
> 
> For the record, the domain for non-negative dividends can be extended to `[0, v + d)`, which is usually larger than `[0, N]`, since `v <= N < v + d`.
> Similarly, the domain for negative dividends can be extended to `(-(v + d), 0)`.

Indeed, however if we go from a given `N` then the solution would be the same.

> src/hotspot/share/opto/divconstants.cpp line 126:
> 
>> 124: //
>> 125: // c * d - rc = 2**s with 0 < rc <= d
>> 126: // qv * v + rv = 2**s with 0 <= rv < v
> 
> To clarify the roles of these quantities, I suggest to extend the comment a bit, like so
> 
> // Let r = m - floor(m / d) * d, that is, let r be the remainder of the indicated floor division.
> // Then
> // c = floor(m / d) + 1, rc = d - r.
> // Further
> // qv = floor(m / v), rv = m - floor(m / v) * d, that is, qv and rv are the quotient,
> // resp., the remainder of the floor division.

Fixed that.

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

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


More information about the hotspot-compiler-dev mailing list