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

Hal Finkel via llvm-dev llvm-dev at lists.llvm.org
Tue Sep 15 07:49:18 PDT 2015


----- Original Message -----
> From: "Steve King" <steve at metrokings.com>
> To: "Hal Finkel" <hfinkel at anl.gov>
> Cc: "Gerolf Hoflehner" <ghoflehner at apple.com>, "llvm-dev" <llvm-dev at lists.llvm.org>, "Wei Mi" <wmi at google.com>
> Sent: Monday, September 14, 2015 1:08:08 PM
> Subject: Re: [llvm-dev] [RFC] New pass: LoopExitValues
> 
> On Fri, Sep 11, 2015 at 10:06 AM, Hal Finkel <hfinkel at anl.gov> wrote:
> > Also, if these redundant expressions involve induction variables,
> > then that's something that the IndVarSimplify is already supposed
> > to do, and if it is missing cases, then we should improve that
> > pass (and, thus, folding what you've done into IndVarSimplify
> > might be the right way to go).
> 
> Hal, thanks for the info.  Turns out IndVarSimplify intentionally
> creates redundant calculation of loop exit values!
> 
> //   2. Any use outside of the loop of an expression derived from the
> indvar
> //      is changed to compute the derived value outside of the loop,
> eliminating
> //      the dependence on the exit value of the induction variable.
>  If the only
> //      purpose of the loop is to compute the exit value of some
> derived
> //      expression, this transformation will make the loop dead.
> 
> I understand the stated purpose for the redundancy, but there is no
> mention of undoing the damage.  The LoopExitValues pass seems to be
> exactly the cleanup that was missing.  Do passes coming after IVS
> like
> LSR need the redundant calculations in place to identify dead loops
> or
> should IVS have cleaned up after itself immediately?

IndVarSimplify deletes dead instructions, and then dead PHIs, but these depend on the in-this-case-temporary redundancy to trivialize dead loops (I assume that SimplifyCFG later removes the remaining now-empty loop blocks).

 -Hal

> 
> Regards,
> -steve
> 

-- 
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory


More information about the llvm-dev mailing list