This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/52876] [x32] - Sign extend 32 to 64bit then clear upper 32bits fails O1 or higher
- From: "hjl.tools at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 05 Apr 2012 13:42:30 +0000
- Subject: [Bug target/52876] [x32] - Sign extend 32 to 64bit then clear upper 32bits fails O1 or higher
- Auto-submitted: auto-generated
- References: <bug-52876-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52876
--- Comment #8 from H.J. Lu <hjl.tools at gmail dot com> 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.