public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "manu at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/64918] invalid (?) warning when initializing structure
Date: Thu, 23 Apr 2015 23:33:00 -0000	[thread overview]
Message-ID: <bug-64918-4-65XfdAoMxc@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-64918-4@http.gcc.gnu.org/bugzilla/>

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

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu.org

--- Comment #6 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Øystein Schønning-Johansen from comment #2)
> Really insightful, Joseph. I do understand the warning a bit better now. I
> have not looked into the GCC parsing code, but based on your description and
> my (limited) understanding of the problem, I guess a fix is not trivial? Can
> I suppress this warning in any way?

I haven't looked at the code, but my guess is that at the time of the warning,
it should be possible to check the overriden initializer, if it is a compound
literal, recur on its initializers and check for side-effects again.
>From gcc-bugs-return-484532-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Apr 23 23:34:38 2015
Return-Path: <gcc-bugs-return-484532-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 39032 invoked by alias); 23 Apr 2015 23:34:37 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 39010 invoked by uid 48); 23 Apr 2015 23:34:33 -0000
From: "jamrial at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/65871] New: bzhi builtin/intrinsic wrongly assumes bzhi instruction doesn't set the ZF flag
Date: Thu, 23 Apr 2015 23:34:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: unknown
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: jamrial at gmail dot com
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter
Message-ID: <bug-65871-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-04/txt/msg02084.txt.bz2
Content-length: 1753

https://gcc.gnu.org/bugzilla/show_bug.cgi?ide871

            Bug ID: 65871
           Summary: bzhi builtin/intrinsic wrongly assumes bzhi
                    instruction doesn't set the ZF flag
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jamrial at gmail dot com

unsigned foo(void);
int main(void)
{
    if (__builtin_ia32_bzhi_si(foo(), foo()))
        return 1;
    return 0;
}

Compiled with -mbmi2 -O3

0000000000000000 <main>:
   0:   53                      push   rbx
   1:   e8 00 00 00 00          call   6 <main+0x6>
   6:   89 c3                   mov    ebx,eax
   8:   e8 00 00 00 00          call   d <main+0xd>
   d:   c4 e2 60 f5 c0          bzhi   eax,eax,ebx
  12:   85 c0                   test   eax,eax
  14:   0f 95 c0                setne  al
  17:   0f b6 c0                movzx  eax,al
  1a:   5b                      pop    rbx
  1b:   c3                      ret

It generates a redundant test instruction. According to
http://www.felixcloutier.com/x86/BZHI.html bzhi already sets the ZF flag on its
own.
Same happens when using inline assembly instead of the builtin to generate the
bzhi instruction. In all cases reproducible with GCC 4.9.2 and GCC 5.1.0.
Didn't test the 4.8 branch or trunk.

This aside, it would be nice if gcc could generate a bzhi instruction on its
own if it detects "X & ((1 << Y) - 1)" where Y is not a constant, same as it
does for several other bmi and tbm instructions, instead of needing to use the
builtin (Which is only available when targeting bmi2).
I can open a new bug report for that if needed.


  parent reply	other threads:[~2015-04-23 23:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-03 13:43 [Bug c/64918] New: " oystein at gnubg dot org
2015-02-03 15:47 ` [Bug c/64918] " joseph at codesourcery dot com
2015-02-03 16:38 ` oystein at gnubg dot org
2015-02-03 17:33 ` joseph at codesourcery dot com
2015-04-20 15:14 ` mpolacek at gcc dot gnu.org
2015-04-23 22:44 ` mpolacek at gcc dot gnu.org
2015-04-23 23:33 ` manu at gcc dot gnu.org [this message]
2015-05-07 22:15 ` mpolacek at gcc dot gnu.org
2021-01-05 16:57 ` mpolacek 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-64918-4-65XfdAoMxc@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).