unroller patch

Jeffrey A Law law@hurl.cygnus.com
Sat Feb 6 10:08:00 GMT 1999

I've installed this patch from Jim.

------- Forwarded Message

From:     Jim Wilson <wilson@cygnus.com>
To:       law@cygnus.com
Date:     Fri, 05 Feb 1999 21:19:40 -0800
Subject:  Re: Another recombine_givs problem 

	Compile x-hppa1.1-hp-hpux10.20 with -O2 -funroll-loops to make the
	compiler abort.
	If I disable recombine_givs it compiles fine.

We have a giv with dest_reg 105 that is combined with a giv with dest_reg
102 that is derived from a giv with dest_reg 101.  

In find_splittable_givs, the test (v->same && v->same->derived_from) is
true, so we call express_from, and the giv for reg 105 gets a new_reg value
which is (plus (reg 101) (const_int 8)).  This causes reg 101 to be marked
as splittable.

reg 101 has an add_val of (reg 99) and a mult_val of (const_int 1), and a
src_reg of (reg 94).  It is set inside the loop with this insn.

(insn 27 26 29 (set (reg:SI 101)
        (plus:SI (reg/v:SI 94)
            (reg/v:SI 99))) 169 {addsi3} (nil)

Since it was marked splittable, loop unrolling calls calculate_giv_inc to
figure out the increment amount, and it fails because there isn't one.

I believe the problem here is that we shouldn't have used 101 for 
new_reg in the first place.  reg 101 has already been reduced to reg 107,
which is its new_reg value.  The new_reg for giv 105 should be based off the
new_reg for 101.  Hence it should have been (plus (reg 107) (const_int 8).

express_from is called before givs are reduced everywhere except the two
most recently added calls in unroll.  Thus I think the problem is that
we either shouldn't be using express_from, or else we need to be fixing
the result we get back from express_from.

I tried the latter.  The core dump is gone now, and the RTL appears to be
reasoanbly correct.

Fri Feb  5 21:13:46 1999  Jim Wilson  <wilson@cygnus.com>

	* unroll.c (find_splittable_givs): After express_from, call replace_rtx
	to convert dest_reg to new_reg.

Index: unroll.c
RCS file: /cvs/cvsfiles/devo/gcc/unroll.c,v
retrieving revision 1.104
diff -p -r1.104 unroll.c
*** unroll.c	1999/02/05 06:59:44	1.104
- --- unroll.c	1999/02/06 05:16:23
*************** find_splittable_givs (bl, unroll_type, l
*** 2912,2917 ****
- --- 2912,2919 ----
  		      same = same->derived_from;
  		      new_reg = express_from (same, v);
+ 		      new_reg = replace_rtx (new_reg, same->dest_reg,
+ 					     same->new_reg);
  		  /* If the address giv has a constant in its new_reg value,
*************** find_splittable_givs (bl, unroll_type, l
*** 3028,3033 ****
- --- 3030,3037 ----
  		      v->same = v->same->derived_from;
  		      v->new_reg = express_from (v->same, v);
+ 		      v->new_reg = replace_rtx (v->new_reg, v->same->dest_reg,
+ 						v->same->new_reg);

------- End of Forwarded Message

More information about the Gcc-patches mailing list