[parisc-linux] pa reload problem

Alan Modra alan@linuxcare.com.au
Fri, 1 Dec 2000 11:23:42 +1100 (EST)


Hi Dave, Jeff,
  This little testcase triggers a bug on hppa64.  It's been around for
quite a while, so it's not something due to Dave's recent changes.

*******
extern void foo (int);
extern unsigned int cpu_hz;

int hppa_dp_bug (void)
{
  foo (42);
  return (5 * ((unsigned long)cpu_hz / 1000000UL));
}
*******

-O2 generates code like

        b,l foo,%r2
        copy %r27,%r4
        addil LT'cpu_hz,%r4	! know r27 trashed in call, so use r4
        ldd RT'cpu_hz(%r1),%r1
        ldd -144(%r30),%r2
        ldw 0(%r1),%r19
        addil LT'L$C0000,%r27	! oops, should be using r4
        ldd RT'L$C0000(%r1),%r1

The bad code codes from config/pa/pa.c:legitimize_pic_address

  if (GET_CODE (orig) == SYMBOL_REF)
    {
      if (reg == 0)
	abort ();

      if (flag_pic == 2)
	{
	  emit_move_insn (reg,
			  gen_rtx_PLUS (word_mode, pic_offset_table_rtx,
					gen_rtx_HIGH (word_mode, orig)));

To fix the problem, it seems to me that we should be testing whether
pic_offset_table_rtx is valid at this point, and if not, use the saved reg
instead.  I'm not exactly sure how to go about testing whether r27 is
valid here, and I'm sure one of you can point me in the right direction.

Alan Modra
-- 
Linuxcare.  Support for the Revolution.