public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "amonakov at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/107099] New: uncprop a bit
Date: Fri, 30 Sep 2022 14:41:32 +0000	[thread overview]
Message-ID: <bug-107099-4@http.gcc.gnu.org/bugzilla/> (raw)

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).

             reply	other threads:[~2022-09-30 14:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-30 14:41 amonakov at gcc dot gnu.org [this message]
2022-10-06  8:53 ` [Bug tree-optimization/107099] uncprop a bit too eager rguenth at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-107099-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).