[LLVMdev] IndVarSimplify too aggressive ?

Andrew Trick atrick at apple.com
Tue Mar 15 17:15:47 PDT 2011


On Mar 13, 2011, at 2:01 PM, Arnaud Allard de Grandmaison wrote:

> Hi all,
> 
> The IndVarSimplify pass seems to be too aggressive when it enlarge the induction variable type ; this can pessimize the generated code when the new induction variable size is not natively supported by the target. This is probably not an issue for x86_64, which supports natively all types, but it is a real one for several embedded targets, with very few native types.
> 
> I attached a patch to address this issue; if TargetData is available, the patch attempts to keep the induction variable to a native type when going thru the induction variable users.
> 
> Also attached my test-case in C, as well as the resulting assembly output, with and without the patch applied, for arm and x86_32 targets. You will note the loop instructions count can be reduced by 30% in several cases.
> 
> The patch could probably be made smarter : I am welcoming all suggestions.
> 
> Best Regards,
> --
> Arnaud de Grandmaison


Arnaud,

I've been investigating whether it's safe to apply your patch. I still need to understand why our generated code is slower in some cases. I noticed a particularly bad regression in 
MultiSource/Benchmarks/FreeBench/fourinarow/fourinarow that I documented here:
http://llvm.org/bugs/show_bug.cgi?id=9490

We would like to avoid generating canonical induction variables in IndVarSimplify. Once that work is complete, your patch should no longer be needed. Although in the meantime, it would be nice to understand why promoting IVs to wider types is sometimes required for codegen.

-Andy



More information about the llvm-dev mailing list