RFR: 8320725: C2: Add "is_associative" flag for floating-point add-reduction [v3]

Emanuel Peter epeter at openjdk.org
Fri Mar 22 05:43:25 UTC 2024


On Thu, 21 Mar 2024 20:38:17 GMT, Bhavana Kilambi <bkilambi at openjdk.org> wrote:

>> src/hotspot/share/opto/vectornode.hpp line 270:
>> 
>>> 268:   // when it is auto-vectorized as auto-vectorization mandates the operation to be
>>> 269:   // non-associative (strictly ordered).
>>> 270:   bool _is_associative;
>> 
>> Could this be a `const`?
>
> Hi, what is the reason to declare it as a `const`? It is declared as a `private` member variable with no "setter" function either. It is not easy to modify this value from any other part of the code anyway.

Generally, it is better to declare things `const` if they can be. It tells the reader of the code that the field will never be changed. Even if things are fine now, a future contributor might misunderstand how the field is to be used, and start modifying it in a `Ideal` method for example.
But if it is not simple to make it `const` for some reason, then don't do it.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18034#discussion_r1535079275


More information about the hotspot-compiler-dev mailing list