From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13615 invoked by alias); 19 Mar 2011 12:35:23 -0000 Received: (qmail 13481 invoked by uid 22791); 19 Mar 2011 12:35:22 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 19 Mar 2011 12:35:17 +0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/48197] possible wrong code bug at -O0 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jakub at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Sat, 19 Mar 2011 14:22:00 -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 X-SW-Source: 2011-03/txt/msg02092.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48197 --- Comment #8 from Richard Guenther 2011-03-19 12:34:55 UTC --- (In reply to comment #7) > I think the bug is in shorten_compare. > We are called for GT_EXPR with op0 0LL and op1 (unsigned) (short) ((short) 0 ^ > (short) y) > with long long result type. ^ above is BIT_XOR_EXPR with short type (shortened > earlier, but that's fine, (unsigned) (short) ((short) 0 ^ (short y)) is still > (unsigned) (short) y, i.e. sign extending y from 16 bits to 32 bits. In the > above the (short) cast doesn't really exist, it is simply a NOP_EXPR with > unsigned int type of BIT_XOR_EXPR with short int type. > get_narrower gives us 0LL (no change, unsignedp0 set to 0) and the short int > BIT_XOR_EXPR (again, with unsignedp1 set to 0). That is IMHO also fine, > unsignedp1 says that the BIT_XOR_EXPR needs to be sign extended to the type. > > But in the end shorten_compare says that the comparison just should be done in > short int, which is wrong. Ah, one of my special friends and endless source of wrong-code bugs ;) Can we just remove this premature frontend optimization?