Bug 38034 - Unnecessary register move
Summary: Unnecessary register move
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: 4.5.0
Assignee: Not yet assigned to anyone
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: ra
Depends on:
Blocks:
 
Reported: 2008-11-06 18:09 UTC by H.J. Lu
Modified: 2009-03-30 16:59 UTC (History)
2 users (show)

See Also:
Host:
Target: ia64-unknown-linux-gnu
Build:
Known to work: 4.5.0
Known to fail: 4.4.0
Last reconfirmed:


Attachments
gcc44-pr38034.patch (388 bytes, patch)
2008-11-06 21:41 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2008-11-06 18:09:04 UTC
[hjl@gnu-14 prev-gcc]$ cat /tmp/x.c
#include <ia64intrin.h>

int
foo (int *p)
{
  return __sync_lock_test_and_set (p, 0);
}
[hjl@gnu-14 prev-gcc]$ ./xgcc -B./ -O2 -S /tmp/x.c 
[hjl@gnu-14 prev-gcc]$ cat x.s
	.file	"x.c"
	.pred.safe_across_calls p1-p5,p16-p63
	.text
	.align 16
	.align 64
	.global foo#
	.type	foo#, @function
	.proc foo#
foo:
	.prologue
	.body
	.mmi
	nop 0
	mov r8 = r0
	nop 0
	;;
	.mib
	xchg4 r8 = [r32], r8
	nop 0
	br.ret.sptk.many b0
	.endp foo#
	.ident	"GCC: (GNU) 4.4.0 20081106 (experimental) [trunk revision 141649]"
[hjl@gnu-14 prev-gcc]$ 

We don't need

mov r8 = r0

We should generate

xchg4 r8 = [r32], r0
Comment 1 Jakub Jelinek 2008-11-06 21:41:20 UTC
Created attachment 16629 [details]
gcc44-pr38034.patch

Untested patch to fix it.
Comment 2 H.J. Lu 2009-02-13 21:58:29 UTC
A patch is posted at

http://gcc.gnu.org/ml/gcc-patches/2009-02/msg00674.html
Comment 3 hjl@gcc.gnu.org 2009-03-27 22:28:32 UTC
Subject: Bug 38034

Author: hjl
Date: Fri Mar 27 22:28:20 2009
New Revision: 145135

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145135
Log:
gcc/

2009-03-27  H.J. Lu  <hongjiu.lu@intel.com>
	    Jakub Jelinek  <jakub@redhat.com>

	PR target/38034
	* config/ia64/sync.md (cmpxchg_rel_<mode>): Replace input
	gr_register_operand with gr_reg_or_0_operand.
	(cmpxchg_rel_di): Likewise.
	(sync_lock_test_and_set<mode>): Likewise.

gcc/testsuite/

2009-03-27  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/38034
	* gcc.target/ia64/sync-1.c: New.

Added:
    trunk/gcc/testsuite/gcc.target/ia64/sync-1.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/ia64/sync.md
    trunk/gcc/testsuite/ChangeLog

Comment 4 Steve Ellcey 2009-03-30 16:59:31 UTC
Closing this out since it is now fixed for 4.5.