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

Fei Gao fgao at openjdk.org
Wed Jul 19 02:24:44 UTC 2023


On Tue, 18 Jul 2023 15:58:01 GMT, Richard Reingruber <rrich at openjdk.org> wrote:

>> Thanks for your review!
>> 
>> For vectorapi masked operations, like `av.neg().lanewise(VectorOperators.FMA, bv, cv, mask)`, the inactive lanes of the output should save the first input of the node, so the inactive lanes of the output should be equal to lane values in `av.neg()`. If we exchange the inputs, the inactive lanes will be equal to `bv`, which is incorrect. So we shouldn't swap edges for masked nodes. The newly added testcases in ` jdk/test/hotspot/jtreg/compiler/vectorapi/VectorFusedMultiplyAddSubTest.java` can cover this. Fortunately, there is no such constraint for non-masked vector nodes.
>
> Thanks for the explanation. I think I understood it to some degree.
> What happens with the subgraphs that are not canonicalized? They will have extra vector operations, right?

Yes. For `av.neg().lanewise(VectorOperators.FMA, bv, cv, mask)`, the subgraph is like:
`match (Set dst (FmaV (Binary (NegV src1) src2) (Binary src3 pg)));`, almost all platforms don't support fuse it directly, so it should be split into two vector operations: `NegV` + `FmaV`. I suppose the `NegV` is what you called as "the extra vector operation", right?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14576#discussion_r1267462815


More information about the hotspot-compiler-dev mailing list