[llvm-commits] [PATCH] - Instcombine vector code optimizations

Chris Lattner clattner at apple.com
Fri Apr 8 22:43:28 PDT 2011


On Apr 7, 2011, at 4:24 AM, Rotem, Nadav wrote:

> Hi, 
> 
> Please review the attached patch. I implemented two main optimizations:
> 
> 1. Getelementptr (PTR, extract (vcast)))  -> Getelementptr (PTR, cast (extract)))  scalarize the casting of pointer index. 
>   This generates much better code in cases where the gep index comes from a vector. 

This seems somewhat reasonable to me in concept.  The code needs to follow the standards through.  Please end comments with proper punctuation, don't evaluate GEP.getNumIndices() each time through the loop, put the "*" in the right place, fit in 80 columns etc.

More seriously, the code doesn't seem to have a reasonable cost model.  What if the cast has multiple uses and is legal?  You're turning one vector cast + a bunch of extracts into multiple extracts and multiple casts.  It is far from clear that this is a good idea.

> 2. Extend the EvaluateInDifferentType and CanEvaluateXXX to support Extract/Insert/ShuffleElement instructions.

Similar comments.  How do you know that you aren't destroying performance by changing long sequences of legal types and legal operations into illegal types/operations?

-Chris



More information about the llvm-commits mailing list