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

Richard Reingruber rrich at openjdk.org
Tue Jul 18 16:04:18 UTC 2023


On Tue, 18 Jul 2023 01:34:48 GMT, Fei Gao <fgao at openjdk.org> wrote:

>> src/hotspot/share/opto/vectornode.cpp line 1879:
>> 
>>> 1877: 
>>> 1878: Node* FmaVNode::Ideal(PhaseGVN* phase, bool can_reshape) {
>>> 1879:   // We canonicalize the node by converting "(-a)*b+c" into "b*(-a)+c"
>> 
>> Could you explain a little bit more please?
>
> 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?

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

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


More information about the hotspot-compiler-dev mailing list