RFR: 8310190: C2 SuperWord: AlignVector is broken, generates misaligned packs [v50]

Emanuel Peter epeter at openjdk.org
Thu Dec 21 14:14:20 UTC 2023


On Wed, 20 Dec 2023 12:24:26 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:

>> Emanuel Peter has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   necessary and sufficient (3) <-> (4)
>
> src/hotspot/share/opto/vectorization.cpp line 906:
> 
>> 904:   //   abs(C_pre) <  aw  AND  C_const % abs(C_pre) != 0
>> 905:   //   -> alignment has effect
>> 906:   //   -> But C_const cannot be aligned with C_pre        -> empty
> 
> As we have discussed offline, I suggest the following:
> 
> 
>   // We look at (4a):
>   //
>   //   abs(C_pre) >= aw
>   //   -> Since C_pre is a power of two, we have C_pre % aw = 0. Therefore, any multiple of C_pre
>   //      (i.e. choosing any value for pre_iter_C_Const) is also aw aligned. In this case, we can
>   //      only satisfy (4a) if C_Const is aw aligned:
>   //
>   //      C_const % aw == 0:
>   //      -> (4a) has a trivial solution since we can choose any value for pre_iter_C_Const.
>   //
>   //      C_const % aw != 0:
>   //      -> (4a) has an empty solution since no pre_iter_C_Const can achieve aw alignment.
>   //
>   //   abs(C_pre) <  aw:
>   //   -> Then for some x > 1: aw = abs(C_pre) * x since aw and C_pre are power of twos.
>   //      If (4a) holds, then the following also holds:
>   //        (C_const + C_pre * pre_iter_C_const) % abs(C_pre) <=>
>   //        (C_const                           ) % abs(C_pre)
>   //
>   //      C_const % abs(C_pre) == 0:
>   //      -> pre_iter_C_const is chosen accordingly such that (4a) is satisfied with the given C_const value.
>   //      -> (4a) has a constrained solution.
>   //
>   //      C_const % abs(C_pre) != 0:
>   //      -> Not "C_const % abs(C_pre) == 0" implies not (4a). Therefore, (4a) has an empty solution since no
>   //         pre_iter_C_Const can achieve aw alignment.

I took your part as inspiration, and wrote this part with more detail

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14785#discussion_r1434125129


More information about the hotspot-compiler-dev mailing list