From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8342 invoked by alias); 5 Apr 2012 13:43:04 -0000 Received: (qmail 8233 invoked by uid 22791); 5 Apr 2012 13:43:03 -0000 X-SWARE-Spam-Status: No, hits=-4.2 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,KHOP_THREADED,TW_OV,TW_SL 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; Thu, 05 Apr 2012 13:42:50 +0000 From: "hjl.tools at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/52876] [x32] - Sign extend 32 to 64bit then clear upper 32bits fails O1 or higher Date: Thu, 05 Apr 2012 13:43:00 -0000 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: hjl.tools 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-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 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: 2012-04/txt/msg00361.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52876 --- Comment #8 from H.J. Lu 2012-04-05 13:42:30 UTC --- The reason why GCC 4.6 works is it uses SImode for Pmode. On trunk, I got [hjl@gnu-6 pr52876]$ cat x.i long long li; long long testfunc(void* addr) __attribute__ ((noinline)); long long testfunc(void* addr) { li = (long long)(int)addr; // next line is important, if the address from pv // has been sign extended with leading ONEs li &= 0xffffffff; return li; } [hjl@gnu-6 pr52876]$ /export/build/gnu/gcc-x32/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/gcc-x32/build-x86_64-linux/gcc/ -S -o x.s -mx32 -O x.i -maddress-mode=long [hjl@gnu-6 pr52876]$ cat x.s .file "x.i" .text .globl testfunc .type testfunc, @function testfunc: .LFB0: .cfi_startproc movslq %edi, %rax movq %rax, li(%rip) ret .cfi_endproc .LFE0: .size testfunc, .-testfunc .comm li,8,8 .ident "GCC: (GNU) 4.8.0 20120403 (experimental)" .section .note.GNU-stack,"",@progbits [hjl@gnu-6 pr52876]$ /export/build/gnu/gcc-x32/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/gcc-x32/build-x86_64-linux/gcc/ -S -o x.s -mx32 -O x.i -maddress-mode=short [hjl@gnu-6 pr52876]$ cat x.s .file "x.i" .text .globl testfunc .type testfunc, @function testfunc: .LFB0: .cfi_startproc movq %rdi, %rax movq %rdi, li(%rip) ret .cfi_endproc .LFE0: .size testfunc, .-testfunc .comm li,8,8 .ident "GCC: (GNU) 4.8.0 20120403 (experimental)" .section .note.GNU-stack,"",@progbits [hjl@gnu-6 pr52876]$ -maddress-mode=long generates the wrong code. We have a POINTERS_EXTEND_UNSIGNED bug.