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

Fei Gao fgao at openjdk.org
Thu Jul 20 09:37:46 UTC 2023


On Thu, 20 Jul 2023 09:07:29 GMT, Richard Reingruber <rrich at openjdk.org> wrote:

>> Hi @reinrich, I'm sorry that I didn't explain the transformation here clearly enough to lead to your misunderstanding.  Let's revisit the comment here.
>> 
>> The example `av.neg().lanewise(VectorOperators.FMA, bv, cv, mask)` I gave here was used to explain the latter part
>> "// except vectorapi masked nodes, since the inactive lanes should
>> // save the first input of the masked node."
>> 
>> It means the pr has no real impact on subgraph or codegen for `FmaV` nodes **with mask**, certainly including `PPC`. Since it doesn't apply the change to vector nodes with mask (`is_predicated_vector()`), and the pr doesn't remove any rules **with mask**. 
>> 
>>> Now on PPC, my understanding would be that with the symmetrical match-rules (removed with this pr) the NegV wouldn't be generated. Is my understanding correct?
>> 
>> The symmetrical match-rules removed with this pr works only for `FmaV` nodes **without mask**. The reason why we can remove them is that here we apply the transformation to these non-masked vector nodes. For example, on `PPC` backend, we removed ` match(Set dst (FmaVF dst (Binary (NegVF src1) src2)));` and kept `match(Set dst (FmaVF dst (Binary src1 (NegVF src2))));`, because all `(-a)*b+c` should be converted into `b*(-a)+c` here. Therefore, even without these removed symmetrical match-rules, whether `(-a)*b+c` or `a*(-b)+c` can be fused and the `NegV` won't be generated, given that the backend supports it.
>> 
>> Thanks.
>
> Thanks. How are `FmaV` nodes with mask handled then? Are they transformed into equivalent nodes without mask?

Actually, there is no handling on `FmaV` nodes **with mask** in this patch, whether in the C2 mid-end or codegen backend. The gvn transformation just skips them. And I suppose `FmaV` nodes with mask can't be transformed into nodes **without mask**, except that C2 can guarantee that the mask is all true (this transformation has not been supported by current C2). Thanks.

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

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


More information about the hotspot-compiler-dev mailing list