[PATCH] Add basic support for removal of load that are fed by a store of an aggregate

Björn Steinbrink bsteinbr at gmail.com
Fri Jan 2 14:03:39 PST 2015


Sorry, forget the log... Here it is.

Björn

2015-01-02 23:02 GMT+01:00 Björn Steinbrink <bsteinbr at gmail.com>:
> 2015-01-02 22:36 GMT+01:00 Chandler Carruth <chandlerc at google.com>:
>>
>> On Fri, Jan 2, 2015 at 1:27 PM, Björn Steinbrink <bsteinbr at gmail.com> wrote:
>>>
>>> If we have a simple load through a GEP that is fed by a store of an
>>> aggregate, we can use the GEP indices to walk the stored aggregate and
>>> extract the appropriate value to replace the load.
>>
>>
>> What's the motivation for this change?
>
> The rust compiler hit a case where not having this optimization caused
> a branch not to be removed. The corresponding issue for rustc is
> https://github.com/rust-lang/rust/issues/20149
>
>> Note that SROA replaces all stores of aggregates with scalar stores of the
>> components specifically so that neither it nor GVN needs to cope with
>> aggregate loads or stores.
>
> SROA did the opposite thing in this case, replacing individual stores
> insertvalues and a store of an FCA. I'm attaching the full output of
> opt -print-after-all -O2 -S for the failing test case given in the
> rust issue. The first SROA creates the FCA store, and later when the
> call to `unwrap` is inlined the existing optimizations can't eliminate
> the branch that comes with it, because of the FCA store.
>
> Björn
-------------- next part --------------
A non-text attachment was scrubbed...
Name: log
Type: application/octet-stream
Size: 186977 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150102/85d5ccbd/attachment.obj>


More information about the llvm-commits mailing list