[PATCH] D98714: [SLP] Add insertelement instructions to vectorizable tree

Alexey Bataev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 18 03:36:00 PDT 2021


ABataev added a comment.

In D98714#2765397 <https://reviews.llvm.org/D98714#2765397>, @dyung wrote:

> In D98714#2764828 <https://reviews.llvm.org/D98714#2764828>, @ABataev wrote:
>
>> In D98714#2764805 <https://reviews.llvm.org/D98714#2764805>, @dyung wrote:
>>
>>> Hi, this change has caused a regression in the codegen for one of our internal tests. Consider the following code:
>>>
>>>   __attribute__((noinline))
>>>   __m256d add_pd_002(__m256d a, __m256d b) {
>>>     __m256d r = (__m256d){ a[0] + a[1], a[2] + a[3], b[0] + b[1], b[2] + b[3] };
>>>     return __builtin_shufflevector(r, a, 0, -1, 2, 3);
>>>   }
>>>
>>> If you compile this with "-g0 -O3 -march=btver2", prior to your commit the compiler would generate the following code for the function:
>>>
>>>   # %bb.0:                                # %entry
>>>           vinsertf128     $1, %xmm1, %ymm0, %ymm0
>>>           vhaddpd %ymm1, %ymm0, %ymm0
>>>
>>> But after your change it is now generating the following code:
>>>
>>>   # %bb.0:                                # %entry
>>>           vextractf128    $1, %ymm1, %xmm2
>>>           vhaddpd %xmm0, %xmm0, %xmm0
>>>           vhaddpd %xmm2, %xmm1, %xmm1
>>>           vperm2f128      $2, %ymm0, %ymm1, %ymm0 # ymm0 = ymm0[0,1],ymm1[0,1]
>>>
>>> From your commit description, it sounds like this is expected and will be fixed in a follow-up commit. Is my understanding of this correct?
>>
>> Hi, could you check if D101555 <https://reviews.llvm.org/D101555> fixes this issue?
>
> Hi, I applied the patch locally and built the compiler, but the generated assembly actually seems it might be worse:
>
>   # %bb.0:                                # %entry
>           vinsertf128     $1, %xmm0, %ymm1, %ymm2
>           vinsertf128     $1, %xmm1, %ymm0, %ymm0
>           vextractf128    $1, %ymm1, %xmm1
>           vhaddpd %ymm2, %ymm0, %ymm0
>           vhaddpd %xmm1, %xmm1, %xmm1
>           vextractf128    $1, %ymm0, %xmm2
>           vunpcklpd       %xmm1, %xmm2, %xmm1     # xmm1 = xmm2[0],xmm1[0]
>           vinsertf128     $1, %xmm1, %ymm0, %ymm0
>           retq

Ok, thanks, will fix it later today.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98714/new/

https://reviews.llvm.org/D98714



More information about the llvm-commits mailing list