[Bug tree-optimization/100173] telecom/viterb00data_1 has 16.92% regression compared O2 -ftree-vectorize -fvect-cost-model=very-cheap to O2 on CLX/ICX, 9% regression on znver3

"pinskia at gcc dot gnu.org via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100173

--- Comment #7 from Drea Pinski <pinskia at gcc dot gnu.org> ---
I have a patch to add simple TARGET_MEM_REF support.
Which gives now:
```
.L4:
        movzwl  (%r9), %esi
        movzwl  -62(%rax), %edi
        addq    $2, %r9
        xorl    %r8d, %r8d
        movzwl  2(%rax), %ecx
        subl    %esi, %edi
        addl    %esi, %ecx
        cmpw    %cx, %di
        cmovge  %r10, %r8
        cmovge  %edi, %ecx
        movzwl  (%rax,%r8), %edi
        movw    %cx, 2(%rdx)
        leal    (%rdi,%rdi), %ecx
        movw    %cx, (%rdx)
        movzwl  -62(%rax), %edi
        movzwl  2(%rax), %ecx
        addl    %esi, %edi
        subl    %esi, %ecx
        xorl    %esi, %esi
        cmpw    %cx, %di
        cmovge  %r10, %rsi
        cmovge  %edi, %ecx
        addq    $8, %rdx
        addq    $4, %rax
        movzwl  -4(%rax,%rsi), %esi
        movw    %cx, -2(%rdx)
        leal    1(%rsi,%rsi), %ecx
        movw    %cx, -4(%rdx)
        cmpq    %rdx, %r11
        jne     .L4
```

That is no branches.
And it is similar to what LLVM gets at -O2.

Note a simple testcase like:
```
int f(int a, int *b, int *d, int *c)
{
    for(int i = 0; i < 1024; i++)
    {
      int t;
      int t1;
      if (b[i] > d[i]) {
        t1 = b[i];
        t = c[i];
      }
      else {
        t1 = d[i];
        t = c[i+2];
      }
      b[i] = t+t1;
    }
}
````
is supported. even if the target_mem_ref is more complex :).
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.