SUBREG GIVs - Suggestion for a quick hack.

Toon Moene toon@moene.indiv.nluug.nl
Wed Oct 1 23:16:00 GMT 1997


I wrote:

> >a factor of 2.5 better.

Thomas Koenig:

> If this stabilizes, quite a number of people will discard their
> vendor's Fortran compilers in favour of g77 :-)

Yeah, I had to be more careful with this - this little (750 line)  
program is extremely dependent on strength reduction; not all  
Fortran code will see a 2.5 time speedup ;-)

It's bs3dvw.f (the 21x21x21 case) from:

http://perso.club-internet.fr/queutey/Linux/Bench/bench.html

Richard Henderson:

>  Actually, that's more a measure of how badly it was
>  sucking before.
>
>  Even with that enabled, we do at best 80% the speed of
>  Digital's Fortran on Alpha EV5, and at worse less than
>  50%.

Aah, but I did two other things:

First I applied the following patch by Jeff Law that fixes the  
suboptimal recognition of GIVs due to removal of some special case  
ARRAY_REF code from expand_expr (see my mail dd 14th of September):

Index: loop.c
===================================================================
RCS file: /cvs/cvsfiles/egcs/gcc/loop.c,v
retrieving revision 1.11
diff -c -3 -p -r1.11 loop.c
*** loop.c	1997/09/11 17:08:01	1.11
--- loop.c	1997/09/18 05:31:23
*************** simplify_giv_expr (x, benefit)
*** 5368,5383 ****
  	  case CONST_INT:
  	  case USE:
  	    /* Both invariant.  Only valid if sum is machine operand.
! 	       First strip off possible USE on first operand.  */
  	    if (GET_CODE (arg0) == USE)
  	      arg0 = XEXP (arg0, 0);

  	    tem = 0;
  	    if (CONSTANT_P (arg0) && GET_CODE (arg1) == CONST_INT)
  	      {
  		tem = plus_constant (arg0, INTVAL (arg1));
  		if (GET_CODE (tem) != CONST_INT)
  		  tem = gen_rtx (USE, mode, tem);
  	      }

  	    return tem;
--- 5368,5394 ----
  	  case CONST_INT:
  	  case USE:
  	    /* Both invariant.  Only valid if sum is machine operand.
! 	       First strip off possible USE on the operands.  */
  	    if (GET_CODE (arg0) == USE)
  	      arg0 = XEXP (arg0, 0);

+ 	    if (GET_CODE (arg1) == USE)
+ 	      arg1 = XEXP (arg1, 0);
+
  	    tem = 0;
  	    if (CONSTANT_P (arg0) && GET_CODE (arg1) == CONST_INT)
  	      {
  		tem = plus_constant (arg0, INTVAL (arg1));
  		if (GET_CODE (tem) != CONST_INT)
  		  tem = gen_rtx (USE, mode, tem);
+ 	      }
+ 	    else
+ 	      {
+ 		/* Adding two invariants must result in an invariant,
+ 		   so enclose addition operation inside a USE and
+ 		   return it.  I have no clue what might break because
+ 		   of this.  */
+ 		tem = gen_rtx (USE, mode, gen_rtx (PLUS, mode,  
arg0, arg1));
  	      }

  	    return tem;

and, of course, I run loop_optimize twice.

I'll try your expr.c patch tonight (that's tomorrow morning for you :-)

Cheers,
Toon.



More information about the Gcc mailing list