CreateOr already simplifies 'or LHS, 0' to LHS. Do the same, just for
LHS == 0.
Details
- Reviewers
reames nikic lebedev.ri
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I believe we've disscussed and we should instead rip out all of such constant folding from IRBuilder.
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. 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.