This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Problems in pr26180.c with own backend


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]