[llvm-dev] [RFC] New pass: LoopExitValues

Wei Mi via llvm-dev llvm-dev at lists.llvm.org
Mon Sep 21 11:13:00 PDT 2015


Maybe it can follow the "Delete dead loops" pass which is after
Induction Variable Simplification pass, so it will not affect existing
exitvalue rewriting optimization in Induction Variable Simplification
to find out and delete dead loops?

Existing pass pipeline:
        Loop-Closed SSA Form Pass
        Loop Pass Manager
          Induction Variable Simplification
          Recognize loop idioms
          Delete dead loops
                                                           <=== New
LoopExitValues
        Function TargetTransformInfo
        Loop Pass Manager
          Unroll loops
        Memory Dependence Analysis

I have the same worry as Philip and Hal that the new LoopExitValues
pass may increase some live range significantly in certain cases
because it reuses value cross outerloop iterations. Like the following
hypothetical case, the value reuse will create a live range living
across loop2, loop3, .... But we can add some simple logic to obviate
such case.

for (int Outer = 0; Outer < Size; ++Outer) {
   for (int Inner = 0; Inner < Size; ++Inner)
      Dst[Outer * Size + Inner] = Src[Outer * Size + Inner] * Val;

   for loop 2.
   for loop 3.
   ...
}

Thanks,
Wei.

On Mon, Sep 21, 2015 at 10:12 AM, Steve King <steve at metrokings.com> wrote:
> Hi Folks, Let's keep this optimization alive.  To summarize: several
> folks voiced general support, but with questions about why existing
> optimizations do not already catch this case.  Deep dive by Wei Mi
> showed that the optimization is most likely not a clean-up of LSR
> sloppiness, but something new.  Follow-up by myself confirmed that the
> redundancy eliminated the LoopExitValues pass exists in the original
> IR from Clang.
>
> As a next step, can we come to consensus on where the LoopExitValues
> optimization belongs?
>
> Regards,
> -steve


More information about the llvm-dev mailing list