public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/107099] New: uncprop a bit
@ 2022-09-30 14:41 amonakov at gcc dot gnu.org
  2022-10-06  8:53 ` [Bug tree-optimization/107099] uncprop a bit too eager rguenth at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: amonakov at gcc dot gnu.org @ 2022-09-30 14:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107099

            Bug ID: 107099
           Summary: uncprop a bit
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: amonakov at gcc dot gnu.org
  Target Milestone: ---

For the following testcase

#include <immintrin.h>

__attribute__((target("avx")))
int f(__m128i a[], long n)
{
    for (long i = 0; i < n; i++)
        if (!_mm_testz_si128(a[i], a[i]))
            return 0;
    return 1;
}

gcc -O2 generates

f:
        test    rsi, rsi
        jle     .L4
        xor     eax, eax
        jmp     .L3
.L10:
        add     rax, 1
        cmp     rsi, rax
        je      .L4
.L3:
        mov     rdx, rax
        sal     rdx, 4
        vmovdqa xmm0, XMMWORD PTR [rdi+rdx]
        xor     edx, edx
        vptest  xmm0, xmm0
        sete    dl
        je      .L10
        mov     eax, edx
        ret
.L4:
        mov     edx, 1
        mov     eax, edx
        ret

Note the redundant assignments to edx in the loop and compare with gcc -O2
-fdisable-tree-uncprop1

Also note that generally uncprop adds a data dependency where only a control
dependency existed, hurting speculative execution (hence more appropriate for
-Os than -O2).

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-10-06  8:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-30 14:41 [Bug tree-optimization/107099] New: uncprop a bit amonakov at gcc dot gnu.org
2022-10-06  8:53 ` [Bug tree-optimization/107099] uncprop a bit too eager rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).