[PATCH] D13378: [SCEV] Recognize simple br-phi patterns

Mehdi Amini via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 2 14:16:37 PDT 2015


> On Oct 2, 2015, at 2:02 PM, Sanjoy Das <sanjoy at playingwithpointers.com> wrote:
> 
> sanjoy added a comment.
> 
> In http://reviews.llvm.org/D13378#258915, @joker.eph wrote:
> 
>> Hi Sanjoyd,
>> 
>> Thanks for the clarification on the Constant Select, isn't it something that could be handled as well? Especially with http://reviews.llvm.org/D13390 coming?
> 
> 
> I'm not sure there is much value in optimizing `ConstantExpr`s in SCEV, because they're compile time constants anyway (though they may need to remain symbolic till link time).  I'd just wait till we see a case where it matters in practice.

In my mind it is not about purely “optimizing” this case in SCEV alone. I was wondering about other transformations (loop for instance) that are relying on the result of SCEV analysis to do more powerful optimizations. I’m not completely sure about how SCEV work but I feel cases like this that are not handled prevent a recurrence from being inferred in a loop for instance. 
Canonicalizing the IR solves the issue "most of the time”, but as shown in http://reviews.llvm.org/D13390 it is not always possible to keep the IR “canonical” at the time you need a SCEV result.
I agree that in general we’d better have some motivational example to drive this, but sometimes the best way to figure out if something can have an impact is to implement it and measure :)
I may try to run some benchmarks tonight to see if this case come up in practice, feel free to commit this without waiting for results from my side since this is just about some (highly) hypothetical speculations.

Thanks!

— 
Mehdi



More information about the llvm-commits mailing list