[llvm-commits] [PATCH] SmallVector specialization

Peter Cooper peter_cooper at apple.com
Wed Feb 15 21:01:28 PST 2012



Sent from my iPhone

On Feb 15, 2012, at 8:27 PM, Chris Lattner <clattner at apple.com> wrote:

> 
> On Feb 15, 2012, at 8:18 PM, Peter Cooper wrote:
> 
>> Hi all
>> 
>> Please review this patch to specialize SmallVector::push_back based on whether the type is POD.  Basically i'm avoiding the call to placement new which was creating null checks on the pointer.  As we know the pointer is never null here this should be safe.
>> 
>> Removal of these null checks allows far more optimization in the common case where we constructed a SmallVector then immediately pushed back into it.  The clang executable on x86_64 darwin Release+Asserts goes from 35373352 to 35181016 bytes, a reduction of 188KB.
> 
> Wow, that's a great result - please commit.  Independent of this patch, can you file an optimizer bugzilla about this?  I think the optimizer should be able to eliminate the null check if it is smarter, though I admit that I haven't looked at the IR.
Thanks :)

I looked into the optimizer. in SimplifyICmpInst we only check for Alloca against null, but this needs a check for GEP of Alloca against null.  That makes the branch resolve to false but the optimizer doesn't always rerun the passes to remove the branches. Anyway, I'll add this as a bug with a suitably reduced test.

Pete
> 
> -Chris



More information about the llvm-commits mailing list