This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Hoist reciprocal invariant out of loop
Hello,
> >>>>> Zdenek Dvorak writes:
>
> Zdenek> Inside invariant analysis, you should use outermost_invariant_loop.
>
> outermost_invariant_loop() documentation states that it returns
> the outermost loop to which the expression could be moved, "the outermost
> loop enclosing LOOP." What if there is no enclosing loop?
>
> When I tried using outermost_invariant_loop(), it seemed to be
> returning the current loop if there was no superloop. In an outermost
> loop, I could not distinguish between a stmt that was invariant (and could
> be hoisted into the BB containing the loop) and one that was not invariant
> to the loop.
the comment is not clear enough, sorry. The value returned is the
outermost superloop of LOOP in that DEF is invariant, or NULL if DEF
is not invariant in LOOP.
So you will get the current loop if DEF is not invariant in any
superloop of LOOP (specially, if it is the outermost loop), and NULL,
in case it is not invariant at all.
Zdenek