[llvm-commits] [Review request] Instcombine: extractvalue from load --> load from gep

Dan Gohman gohman at apple.com
Mon Nov 29 15:20:40 PST 2010


On Nov 29, 2010, at 12:28 PM, Frits van Bommel wrote:

> On Mon, Nov 29, 2010 at 8:20 PM, Dan Gohman <gohman at apple.com> wrote:
>> On Nov 28, 2010, at 2:43 AM, Frits van Bommel wrote:
>> 
>>> <006-instcombine-extractvalue-load-v3.patch><007-instcombine-extractvalue-load-test-v2.patch>_______________________________________________
>> 
>> Why is this needed? Front-ends should emit gep+load instead of
>> load+extractvalue.
> 
> Not all front ends might do that. For instance, it might load both
> fields of a struct if thinks it's going to need them anyway but then
> one gets optimized out.

If it emits both fields as gep+load, then there's no problem.

Basically, it's never desirable to actually do an aggregate load or store.
It may be the case they they can be eliminated by optimization much of the
time, but this can fail in various ways, and when it does, you can get
quite unpleasant results. And even when it does work, the best you'll get
is emit the same gep+load that the front-end could have emitted itself
without any extra analysis.

On Nov 29, 2010, at 12:34 PM, Frits van Bommel wrote:

> On Mon, Nov 29, 2010 at 9:28 PM, Frits van Bommel <fvbommel at gmail.com> wrote:
>> Also, when I accidentally messed this up so it asserted every time it
>> fired clang could no longer compile LLVM. I think the problem was in
>> the passmanager, but I might be misremembering.
> 
> Looks like I misremembered; I just found the file I bugpointed and
> it's called PreAllocSplitting.ll. It doesn't contain any extractvalue
> instructions, so they must've been generated by one or more of the
> passes clang runs at -O3.

This merits a bug report.

Dan





More information about the llvm-commits mailing list