[LLVMdev] getTripCount requires which optimization passes?

Dan Gohman gohman at apple.com
Mon May 10 11:45:48 PDT 2010


On May 7, 2010, at 11:17 AM, Trevor Harmon wrote:

> On May 6, 2010, at 6:32 PM, ether zhhb wrote:
> 
>> As the comment said:
>>  /// The IndVarSimplify pass transforms loops to have a form that  
>> this
>>  /// function easily understands.
>> 
>> you could try -indvars.
> 
> After adding -indvars to the opt command, getTripCount still returns  
> null.

Code coming from C front-ends typically also needs -loop-rotate, in
addition to all the usual stuff (mem2reg, instcombine, simplifycfg, etc).
It depends a fair amount on the front-end; take a look at what opt -O2
does and experiment with it.

> 
> I suppose it's possible, depending on the scheduling of the pass  
> manager, that indvars is running after my pass runs. I could force it  
> to run first by adding it to my pass's getAnalysisUsage:
> 
> void MyPass::getAnalysisUsage(AnalysisUsage &AU) const {
>     AU.addRequired<IndVarSimplify>();
> }
> 
> But this isn't possible because for some reason there's no  
> IndVarSimplify.h header file. The IndVarSimplify pass is defined only  
> in its IndVarSimplify.cpp, so my pass can't use it.

The design idea here is that you should write your pass to be
conservatively correct in the case that indvars and whatever else
hasn't run, and then just make your front-ends add -indvars before
adding your pass.

Dan




More information about the llvm-dev mailing list