From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9349 invoked by alias); 1 Jan 2011 20:54:02 -0000 Received: (qmail 9337 invoked by uid 22791); 1 Jan 2011 20:54:01 -0000 X-SWARE-Spam-Status: No, hits=-2.9 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, 01 Jan 2011 20:53:58 +0000 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/47148] [4.6 Regression] likely wrong code bug X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.6.0 X-Bugzilla-Changed-Fields: Component 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, 01 Jan 2011 20:54: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-01/txt/msg00040.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47148 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- Component|tree-optimization |target --- Comment #3 from Jakub Jelinek 2011-01-01 20:53:39 UTC --- It seems this is very much related to the PR46942 ABI screw up. Apparently sometimes on x86_64 we actually rely on the sign/zero extensions done by the caller, not to DImode, but just to SImode, not by setting SUBREG_PROMOTED_P bit in the subregs, but at least in combine.c's setup_incoming_promotions and thus the zero extension is optimized away. Normally, e.g. when compiling static unsigned a = 1, b = 1; static __attribute__((noinline)) void foo (unsigned char x) { unsigned c = (0x7000U / (x - 2)) ^ 1; b &= c; } int main (void) { foo (1); foo (-1); if (b && ((unsigned char) -1) == 255) __builtin_abort (); return 0; } the caller indeed does the needed promotions, as CALL_EXPR's argument has int type rather than unsigned char. But when calling the artificial foo.part.0, the argument passed to it is unsigned char 255 rather than int 255 and it sets a QImode %rdi register to -1 (i.e. 255) instead of setting SImode %rdi register to 255, which means it is incorrectly sign extended instead of zero extended.