RFR: 8320725: C2: Add "is_associative" flag for floating-point add-reduction [v3]

Bhavana Kilambi bkilambi at openjdk.org
Wed Apr 3 11:15:11 UTC 2024


On Thu, 21 Mar 2024 10:26:16 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

>> Yes, MUL is non-associative in VectorAPI just like ADD operation (according to the description here - https://docs.oracle.com/en/java/javase/19/docs/api/jdk.incubator.vector/jdk/incubator/vector/VectorOperators.html#fp_assoc).
>> 
>> We found a significant perf difference between the SVE "fadda" instruction which is a strictly ordered instruction vs Neon instructions on a 128-bit SVE machine especially after this optimization - https://bugs.openjdk.org/browse/JDK-8298244 but there's no such performance difference for the MUL operation. MulReductionVF/VD do not have direct instructions for multiply reduction nor do they have separate ISA for strictly ordered or non-strictly ordered. So, currently we do not have any data that shows any benefit to add similar code for MUL and thus it's currently considered to be a non-associative operation (strictly ordered). I am not sure about other platforms.
>
> Right. Ok, since your benchmarks are restiricted to NEON/SVE, I can understand these results. But I would think that probably on x86 machines this would look different, it is just that we currently have no unordered float/double add/mul reductions.
> 
> I think it would be nice if you made both Add and Mul capable of being unordered already, that would make future work in this area simpler. Or do you see a regression for unordered mul reductions on your benchmark machines?

Ok, I have added support in the mid-end for Mul operation as well. I don't see any regression on aarch64 as I have not modified the rules for mul reduction in any way. I have not added any aarch64 backend rules for mul reduction as we do not have separate instructions for strictly/non-strictly ordered mul reduction and it makes no sense to add the strict ordering condition for mul reduction on aarch64. However, as you suggested if other platforms do have such instructions, it might benefit them.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18034#discussion_r1549505490


More information about the hotspot-compiler-dev mailing list