RFR: 8308340: C2: Idealize Fma nodes [v5]

Fei Gao fgao at openjdk.org
Mon Aug 14 07:56:35 UTC 2023


On Thu, 10 Aug 2023 13:34:05 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

> We should probably do the verification that the canonicalization happened, if the normal `fma` matcher rule is chosen. We should add asserts that the first argument is not a negation (you could check the second argument also, just in case). What do you think?

Hi @eme64, thanks for your review!

The check may be more complex than expected. Matcher can fuse two instructions into one, only when there is no other use for the inputs. It means that we can do the fusion for the case like:

return Math.fma(-a, b, c);

But we can't fuse them for the case like:

float tmp = -a;
return Math.fma(tmp, b, c) + (-a);

For the second case, we still match normal `neg` + `fma` rules separately, instead of these combined rules. So, we can't simply guarantee that the first argument is not a negation when the normal `fma` matcher rule is chosen. If considering the def-use while doing the instruction selection, the check may be complex. WDYT? Thanks.

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

PR Comment: https://git.openjdk.org/jdk/pull/14576#issuecomment-1676838806


More information about the hotspot-compiler-dev mailing list