[hjl@gnu-6 ilp32-31]$ cat y.c int foo (int *p) { return *p; } [hjl@gnu-6 ilp32-31]$ make y.s /export/build/gnu/gcc-x32/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/gcc-x32/build-x86_64-linux/gcc/ -S -o y.s -mx32 -funroll-all-loops -O3 -dp y.c [hjl@gnu-6 ilp32-31]$ cat y.s .file "y.c" .text .p2align 4,,15 .globl foo .type foo, @function foo: .LFB0: .cfi_startproc mov %edi, %edi # 2 *zero_extendsidi2_rex64/1 [length = 2] movl (%rdi), %eax # 6 *movsi_internal/1 [length = 2] ret # 20 return_internal [length = 1] .cfi_endproc .LFE0: .size foo, .-foo .ident "GCC: (GNU) 4.6.0 20110311 (experimental)" .section .note.GNU-stack,"",@progbits [hjl@gnu-6 ilp32-31]$ We don't need to zero-extend 32bit pointer in EDI to RDI.
The existing testcase is gcc.target/i386/pr32661-1.c.
Author: hjl Date: Sat Apr 2 06:05:03 2011 New Revision: 171878 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=171878 Log: Promote pointer function arguments and return values to Pmode. 2011-03-29 H.J. Lu <hongjiu.lu@intel.com> PR middle-end/47725 PR target/48085 * calls.c (precompute_register_parameters): Convert pointer to TLS symbol if needed. * config/i386/i386.c (ix86_promote_function_mode): New. (TARGET_PROMOTE_FUNCTION_MODE): Likewise. Modified: branches/x32/gcc/ChangeLog.x32 branches/x32/gcc/calls.c branches/x32/gcc/config/i386/i386.c
Current mainline gcc does not generate zero extensions anymore: foo: .LFB0: .cfi_startproc movl (%rdi), %eax # 6 *movsi_internal/1 [length = 2] ret # 20 return_internal [length = 1] .cfi_endproc .LFE0: Fixed.