[LLVMdev] [RFC] Stripping unusable intrinsics

Owen Anderson resistor at mac.com
Mon Dec 29 22:58:00 PST 2014

> On Dec 29, 2014, at 5:51 PM, Mehdi Amini <mehdi.amini at apple.com> wrote:
> A more generic question I have is why does the code that handle “target-specific” intrinsic has to be in the middle-end? I am surprise to see all that X86 specific code in the middle-end.
> Why don’t we expose a hook (TargetMachine?) for the different targets to handle their own intrinsics their own way?
> InstCombine, ConstantFolding, AliasAnalysis, … would fallback to the target to handle non-generic intrinsic. 

This is what I was getting at when I said that I think there could be a better separation of concerns with respect to the handling of target specific intrinsics, which could move some of their handling into the targets themselves on hooks that can be invoked from generic passes.

As to why we need to optimize them, just consider constant folding.  It’s quite possible for constant-foldable forms of target-specific intrinsics to arise from macros, template expansions, etc.  It’s important that we do that constant folding as early as possible because it can affect later decisions like inlining, loop unrolling, etc.  If we can’t constant fold the target-specific operation until after the middle-end, then we’ve potentially lost out.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141229/355e11cb/attachment.html>

More information about the llvm-dev mailing list