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

Fix loop hoisting code and USEs



Hi
The loop hoisting code currently ignores USEs inside movables happily hoisting
instruction outside loop w/o moving the code to compute the used value.
This causes some missoptimizations on i386, for example in the loop

int a;
float b;
main ()
{
  int i;
  for (i = 0; i < 100; i++)
    a = b;
}

The fldcw/fist/fstcw is hoisted, but the fsntcw remains inside loop.

Honza

Pá čec 13 22:36:22 CEST 2001  Jan Hubicka  <jh@suse.cz>
	* loop.c (scan_loop): Add USEs inside PARALLELs into dependencies
	of the movable.
*** loop.c.old	Fri Jul 13 21:57:24 2001
--- loop.c	Fri Jul 13 22:35:47 2001
*************** scan_loop (loop, flags)
*** 705,710 ****
--- 705,722 ----
  		}
  	    }
  
+ 	  /* For parallels, add any possible uses to the depencies, as we can't move
+ 	     the insn without resolving them first.  */
+ 	  if (GET_CODE (PATTERN (p)) == PARALLEL)
+ 	    {
+ 	      for (i = 0; i < XVECLEN (PATTERN (p), 0); i++)
+ 		{
+ 		  rtx x = XVECEXP (PATTERN (p), 0, i);
+ 		  if (GET_CODE (x) == USE)
+ 		    dependencies = gen_rtx_EXPR_LIST (VOIDmode, XEXP (x, 0), dependencies);
+ 		}
+ 	    }
+ 
  	  /* Don't try to optimize a register that was made
  	     by loop-optimization for an inner loop.
  	     We don't know its life-span, so we can't compute the benefit.  */


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