RFR: 8322758: Eliminate -Wparentheses warnings in C2 code

Andrew Haley aph at openjdk.org
Fri Dec 29 18:23:38 UTC 2023


On Fri, 29 Dec 2023 02:01:08 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

> Please review this change to eliminate some -Wparentheses warnings.  In most
> cases, this involved simply adding a few parentheses to make some implicit
> operator precedence explicit.
> 
> In PhaseIdealLoop::rc_predicate, I also added a comment describing the test
> being performed, since it didn't seem obvious even with the additional
> parentheses.
> 
> Testing: mach5 tier1
> 
> Also ran mach5 tier1 with these changes in conjunction enabling -Wparentheses
> and other changes needed to make that work.

Marked as reviewed by aph (Reviewer).

src/hotspot/share/opto/loopPredicate.cpp line 801:

> 799:   const TypeInt* idx_type = TypeInt::INT;
> 800:   // same signs and upper, or different signs and not upper.
> 801:   if (((stride > 0) == (scale > 0)) == upper) {

This is rather l33t code, but I guess it's OK with the comment. This
Suggestion:

  _Bool same_signs = (stride > 0) == (scale > 0);
  if ((same_signs & upper)
      || (!same_signs && !upper)) {

generates slightly more code with GCC -O2.  I'd be happy with either.

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

PR Review: https://git.openjdk.org/jdk/pull/17199#pullrequestreview-1799153875
PR Review Comment: https://git.openjdk.org/jdk/pull/17199#discussion_r1438363723


More information about the hotspot-compiler-dev mailing list