This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fix loop hoisting code and USEs
- To: rth at cygnus dot com, gcc-patches at gcc dot gnu dot org, patches at x86-64 dot org
- Subject: Fix loop hoisting code and USEs
- From: Jan Hubicka <jh at suse dot cz>
- Date: Sat, 14 Jul 2001 01:06:56 +0200
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. */