[PATCH] D116817: [IRBuilder] Simplify 'or 0, RHS' -> RHS on creation.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 10 05:55:24 PST 2022


fhahn added a comment.

In D116817#3227912 <https://reviews.llvm.org/D116817#3227912>, @fhahn wrote:

> In D116817#3227871 <https://reviews.llvm.org/D116817#3227871>, @nikic wrote:
>
>> IRBuilder accepts a Folder that currently gives you the choice between no folding, target-independent constant folding and target-dependent constant folding. If we change the API to not be restricted to Constants, we could add a SimplifyFolder that calls into InstSimplify instead.
>>
>> Maybe that would help more generally for what you're currently doing? We could generate code in the straightforward way, but let IRBuilder fold away trivial identities via simplification, without having to reimplement them.
>
> I think it might make sense to provide a InstSimplifyFolder in general, but it looks like this will require some larger changes, as at the moment all folders only seem to support constants.

I put up a patch that adds an inst-simplify based folder as an alternative: D116935 <https://reviews.llvm.org/D116935>. It is very much focused on transitioning one function at a time, starting with `Or` simplification. I'm not sure which other use cases people have in mind, it would be good to hear about them.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D116817/new/

https://reviews.llvm.org/D116817



More information about the llvm-commits mailing list