public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Problems in pr26180.c with own backend
@ 2012-11-14 14:03 Andreas Geißler
  2012-11-14 23:15 ` Georg-Johann Lay
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Geißler @ 2012-11-14 14:03 UTC (permalink / raw)
  To: gcc-help

Hi. I need your help again. I wrote my own backend for the gcc-4.6.2
and with your help it works nearly perfectly.
But i have a problem with the test case pr26180.c. The compiler does
not load the register, which
is used for the comparison. And i don't get why.

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

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

        ;;x2 = x
	xori.l		r8,-1
	addi.l		r8,1

_L2:
       ;;x2 = -x
...


If i only change the comparison integer from 0 to 1 the translation
works correct:


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

Correct 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
	sbs		Z
	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:
...

The translation works also correctly if i use "if else" instead of "?:".
So i you would like to ask you, which pattern is related to "x2 = (x >
0 ? x : (-x));"
or where i should search for this problem.

Thanks in advance.

Best regards,
Andreas

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

* Re: Problems in pr26180.c with own backend
  2012-11-14 14:03 Problems in pr26180.c with own backend Andreas Geißler
@ 2012-11-14 23:15 ` Georg-Johann Lay
  2012-11-19 12:47   ` Andreas Geißler
  0 siblings, 1 reply; 3+ messages in thread
From: Georg-Johann Lay @ 2012-11-14 23:15 UTC (permalink / raw)
  To: Andreas Geißler; +Cc: gcc-help

Andreas Geißler schrieb:
> Hi. I need your help again. I wrote my own backend for the gcc-4.6.2
> and with your help it works nearly perfectly.
> But i have a problem with the test case pr26180.c. The compiler does
> not load the register, which
> is used for the comparison. And i don't get why.
> 
> C-Code:
> ...
> x2 = (x > 0 ? x : (-x));
> ...
> 
> Wrong translated assembler code:
> ...

Assembler don't tell anything; look at TL dump with -da, -fdump-rtl-all 
or -fdump-rtl-all-details.

You might also want so set -dp and / or -dP and / or -fverbose-asm to 
see insns along with assembly.

> The translation works also correctly if i use "if else" instead of "?:".
> So i you would like to ask you, which pattern is related to "x2 = (x >
> 0 ? x : (-x));"

Who knows if not you? That depends on your backend: Maybe absXX2, maybe 
movXXcc, maybe jumping around and movXX and negXX2, ...

> or where i should search for this problem.

Look at .expand dump and track until where it gets wrong.  Presumably a 
wrong expander, wrong constraints (missing early clobber), wrong 
peephole, whatever.

Johann

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

* Re: Problems in pr26180.c with own backend
  2012-11-14 23:15 ` Georg-Johann Lay
@ 2012-11-19 12:47   ` Andreas Geißler
  0 siblings, 0 replies; 3+ messages in thread
From: Andreas Geißler @ 2012-11-19 12:47 UTC (permalink / raw)
  To: Georg-Johann Lay; +Cc: gcc-help

Thanks to your help, i could find the problem. And you're absolutely right,

> Who knows if not you? That depends on your backend: Maybe absXX2, maybe
> movXXcc, maybe jumping around and movXX and negXX2, ...

It was absXX2.

> Look at .expand dump and track until where it gets wrong.  Presumably a
> wrong expander, wrong constraints (missing early clobber), wrong peephole,
> whatever.

wrong expander.

Many thanks again.

Andreas

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

end of thread, other threads:[~2012-11-19 12:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-14 14:03 Problems in pr26180.c with own backend Andreas Geißler
2012-11-14 23:15 ` Georg-Johann Lay
2012-11-19 12:47   ` 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).