[llvm-dev] [RFC] Generalized Pattern Matching & InstSimplify

Florian Hahn via llvm-dev llvm-dev at lists.llvm.org
Mon Nov 30 02:28:22 PST 2020


Hi

> On Nov 25, 2020, at 16:45, Simon Moll via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> Hi,
> 
> How can we make InstSimplify/InstCombine work with intrinsics?
> 
> This RFC proposes generalized pattern matching to lift LLVM's existing InstSimplify to work on intrinsics as well as on regular instructions. For details, technical discussion, please refer to:
> 
>     https://reviews.llvm.org/D92086 <https://reviews.llvm.org/D92086>
> The patch includes tests where InstSimplify optimizes @llvm.vp.add and @llvm.experimental.contrained.fadd as a proof of concept.
> 
> The idea is to pretend that the intrinsics were the actual instruction (eg an fadd) and run the existing InstSimplify logic. We augment pattern matching with a context object - if during pattern matching the context object is no longer sure that the intrinsics are a safe match (eg because there may be fp exceptions that we need to preserve), it aborts the match. In effect, only legal simplifications are performed.
> 
> We expect the approach to work as well for the [proposed] complex arithmetic intrinsics (by masking regular `fmul` and making `llvm.complex.fmul` pass as `fmul` instead).
> 

Thanks for sharing the RFC. It looks like this should be flexible enough to handle a wide range of intrinsics that can be mapped to IR instructions in InstSimplify!

Do you think this approach would also work for InstCombine? Unfortunately there are lots of places that pass references to actual IR instructions to helper functions, rather than (OpCode, Operands…) as instSimplify. 

Cheers,
Florian


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201130/4b7b8b80/attachment.html>


More information about the llvm-dev mailing list