public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* pr26180.c
@ 2012-11-14 13:37 Andreas Geißler
  2012-11-14 14:54 ` pr26180.c Ian Lance Taylor
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Geißler @ 2012-11-14 13:37 UTC (permalink / raw)
  To: gcc-help

Hi.
I need your help again. I wrote my own backend for the gcc-4.6.2 and
it works nearly perfectly. But there is a problem with the test case
pr26180.c.
In this special case the register (r8), which is used for the
comparison, is not loaded. And i don't get why.

C-Code (pr26180.c):
...
x2 = ((x > 0)? (x): -(x));
...

Wrong translated assembler code:
...
        ;x > 0?
	cmpi.l	r8,-2147483648       <- r8 is not used in the hole function
and so it is not initialized with x
	jmp		C,_L2
	
xori.l	        r8,-1
	addi.l  	r8,1
_L2:
...

If i only change the comparison integer from 0 to 1 all works fine:

C-Code:
...
x2 = (x > 1 ? x : (-x));
...

Translated assembler code:
...
        ;load r8
	mov.l		r8,fp
	addi.l		r8,4
	mov.l		r9,r8
	ldr.l		r8,r9

        ;x > 1?
	cmpi.l	r8,-1
	jmpn		N,_L2

        ;x2 = -x
	mov.l		r8,fp
	addi.l		r8,4
	mov.l		r9,r8
	ldr.l		r8,r9
	xori.l		r8,-1
	addi.l		r8,1
	jmp		T,_L3
_L2:
        ;x2 = x
	mov.l		r8,fp
	addi.l		r8,4
	mov.l		r9,r8
	ldr.l		r8,r9
_L3:
...

So i you would like to ask you, which special pattern (machine
description pattern (*.md))
is related to "x2 = ((x > 0)? (x): -(x));" or where should i search the problem.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: pr26180.c
  2012-11-14 13:37 pr26180.c Andreas Geißler
@ 2012-11-14 14:54 ` Ian Lance Taylor
  2012-11-14 15:06   ` pr26180.c Andreas Geißler
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Lance Taylor @ 2012-11-14 14:54 UTC (permalink / raw)
  To: Andreas Geißler; +Cc: gcc-help

On Wed, Nov 14, 2012 at 5:37 AM, Andreas Geißler <setjem@googlemail.com> wrote:
>
> So i you would like to ask you, which special pattern (machine
> description pattern (*.md))
> is related to "x2 = ((x > 0)? (x): -(x));" or where should i search the problem.

The way to debug this kind of problem is to run GCC with
-fdump-rtl-all.  Then read the RTL files back to front until you find
the place where the generated code is erroneous.  For a
machine-specific problem like this it will normally happen sometime in
the register allocation pass or later.

Ian

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: pr26180.c
  2012-11-14 14:54 ` pr26180.c Ian Lance Taylor
@ 2012-11-14 15:06   ` Andreas Geißler
  0 siblings, 0 replies; 3+ messages in thread
From: Andreas Geißler @ 2012-11-14 15:06 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-help

Thanks for the quick response.

This option was it, what i was searching for. if I had known this earlier,
I would have avoided lots of problems.

Thank you very very much.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-11-14 15:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-14 13:37 pr26180.c Andreas Geißler
2012-11-14 14:54 ` pr26180.c Ian Lance Taylor
2012-11-14 15:06   ` pr26180.c Andreas Geißler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).