This is the mail archive of the gcc-bugs@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]

egcs 1.02 and Hitachi SH Target


Hi,
   I'm using egcs 1.02 targeted for sh-elf, and I believe I've found
a bug. I've debugged it as far as I can, but I need some help. Let me
describe the bug. This piece of code:

int j;
long Array[200];
g()
{
    f(Array[j & 0x3f]); 
} 

compiles wrong with optimizations on (-O[123]). The "j & 0x3f" is the
problem, specifically. "j & 0x7f" also fails, but all other mask
values I tried seem to work. Here is a snippet of what it generates:

	mov.l	.L2,r2
	mov.l	.L3,r1
	mov.l	@r1,r1
	shll2	r1
	extu.w	r1,r1            ; Incorrect!
	mov	r2,r0
	mov.l	@(r0,r1),r4
	mov.l	.L4,r0
	jsr	@r0
	nop

gcc 2.7.2.1 targeted for sh-hms generates this code:

	mov.l	L2,r1
	mov.l	@r1,r0
	and	#63,r0               ; Correct!
	shll2	r0
	mov.l	L3,r1
	mov.l	@(r0,r1),r4
	mov.l	L4,r0
	jsr	@r0
	nop

I have done a compile with the dump option ("-dapA") and all the rtl
code has the "and" instruction in it , so I'm guessing the problem
occurs in the part of gcc that translates rtl to sh assembly. I've
looked at the sh specific files, and while I don't understand them
very well, I'm guessing the problem involves the function
gen_shl_and() in gcc/config/sh/sh.c.

Here is more info about my setup:
! GNU C version egcs-2.90.27 980315 (egcs-1.0.2 release) (sh-elf) compiled
by GNU C version NeXT DevKit-based CPP 4.0.

Thank you in advance,
  David



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