Bug 48085 - [x32] Unnecessary zero-extension
Summary: [x32] Unnecessary zero-extension
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: 4.7.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-12 01:54 UTC by H.J. Lu
Modified: 2011-07-28 16:01 UTC (History)
0 users

See Also:
Host:
Target: x32
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2011-03-12 01:54:33 UTC
[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.
Comment 1 H.J. Lu 2011-03-19 15:03:05 UTC
The existing testcase is gcc.target/i386/pr32661-1.c.
Comment 2 hjl@gcc.gnu.org 2011-04-02 06:05:06 UTC
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
Comment 3 Uroš Bizjak 2011-07-28 16:01:20 UTC
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.