From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 37810 invoked by alias); 23 Apr 2015 23:33:22 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 37768 invoked by uid 48); 23 Apr 2015 23:33:17 -0000 From: "manu at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 4.9.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: manu at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: mpolacek at gcc dot gnu.org X-Bugzilla-Target-Milestone: 6.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-04/txt/msg02083.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D64918 Manuel L=C3=B3pez-Ib=C3=A1=C3=B1ez changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |manu at gcc dot gnu.org --- Comment #6 from Manuel L=C3=B3pez-Ib=C3=A1=C3=B1ez --- (In reply to =C3=98ystein Sch=C3=B8nning-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 warni= ng, it should be possible to check the overriden initializer, if it is a compou= nd 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: 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: List-Archive: List-Post: List-Help: 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" 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: 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?id=65871 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
: 0: 53 push rbx 1: e8 00 00 00 00 call 6 6: 89 c3 mov ebx,eax 8: e8 00 00 00 00 call d 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.