This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [CFG] Unswitching cleanup
- From: Jan Hubicka <jh at suse dot cz>
- To: Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>
- Cc: gcc-pdo at atrey dot karlin dot mff dot cuni dot cz, gcc-patches at gcc dot gnu dot org
- Date: Wed, 1 May 2002 21:42:35 +0200
- Subject: Re: [CFG] Unswitching cleanup
- References: <20020501122042.GA5426@atrey.karlin.mff.cuni.cz>
> Hello.
>
> This patch cleans up the code concerning loop unswitching a lot, removing most
> of the dark magic. It also allows us to really remove the loop when we peel it
> completely (till now we were just leaving it in place, hoping that some
> following optimization pass will get rid of it).
Thanks. I will take a look at it shortly. One thing I was thinking about
is that we may make the unswitching independent on the midrtl just
by using canonicalize_comparison on the condition we get from condtiional
and re-emiting the jump again based on the comparison. I will take a look
how dificult it is to integrate into current design.
> *************** void verify_loop_structure (loops, flags
> *** 1140,1145 ****
> --- 1201,1209 ----
> for (i = 1; i < loops->num; i++)
> {
> loop = loops->parray[i];
> + if (!loop)
> + continue;
> +
This looks fine. I am affrait there is a lot more places we will have
to care NULL pointers tought.
> !
> ! /* Find border hexes. */
What do you mean by the border hexes?
> *************** count_loop_iterations (desc, niter, rnit
> *** 418,427 ****
> unsigned HOST_WIDE_INT abs_diff = 0;
> enum rtx_code cond = desc->cond;
>
> if (desc->grow)
> {
> /* Bypass nonsential tests. */
> ! if (cond == GE || cond == GT || cond == GEU || cond == GTU)
> return false;
> if (rniter)
> {
> --- 432,449 ----
> unsigned HOST_WIDE_INT abs_diff = 0;
> enum rtx_code cond = desc->cond;
>
> + /* Ensure that we always handle the condition to stay inside loop. */
> + if (desc->neg)
> + {
> + cond = reverse_condition (cond);
> + if (cond == UNKNOWN)
> + return false;
> + }
> +
Hmm, how can the UNKNOWNS get here? They can happen only for floats
and we hsould rule them out earlier. I guess I will just add the
test into simple_loop to verify that induction variable is integral.
> *************** count_loop_iterations (desc, niter, rnit
> *** 458,470 ****
> << (GET_MODE_BITSIZE (GET_MODE (desc->var)) - 1)
> << 1) - 1;
>
> - if (desc->neg)
> - {
> - cond = reverse_condition (cond);
> - if (cond == UNKNOWN)
> - return false;
> - }
> -
Uhm, I see it is negated but later. Moving it earlier is definitly
good idea.
Thanks!
I will install your patch as it makes thinks just better and try
to make incremental patch over it. I see it is touchy issue and
it would be nice to get it understandable. I am not sure if it
is possible tought :(
Honza