[PATCH] D22599: GVN-hoist: improve code generation for recursive GEPs

Daniel Berlin via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 21 08:48:30 PDT 2016


On Wed, Jul 20, 2016 at 11:51 PM, David Majnemer <david.majnemer at gmail.com>
wrote:

>
>
> On Wed, Jul 20, 2016 at 6:04 PM, Daniel Berlin <dberlin at dberlin.org>
> wrote:
>
>> FWIW: In gcc, the regeneration is a pair of mutually recursive functions,
>> one called "create_expression_by_pieces" (which is the main interface), and
>> one called "find_or_generate_expression"  (which in turn, calls
>> create_expression_by_pieces for any operand that is itself a complex value
>> expression).
>>
>> Whether you do it similarly, or worklist it, you should have some
>> invariant that each iteration guarantees or whatever.
>>
>> I found mutual recursion easier because you can easily guarantee "at the
>> end of this function we return the thing i need to place in this
>> expression" for one of the functions, and there you go.
>>
>
> Both of these approaches sound find to me, I'd just prefer avoiding the
> creation of unnecessary IR.
>
>

Agreed.
You should build a list of instructions to insert, in order, and only once
you are sure things will succeed, insert it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160721/a0cfd0b5/attachment.html>


More information about the llvm-commits mailing list