[llvm-dev] Heads-up: Handling target-specific intrinsics in InstCombine

30 views
Skip to first unread message

Nicolai Hähnle via llvm-dev

unread,
Jun 29, 2020, 4:59:06 PM6/29/20
to llvm-dev
Hello,

this mail is to raise awareness of https://reviews.llvm.org/D81728,
which is substantial enough of a conceptual change that it should
probably at least be mentioned in llvm-dev.

InstCombine has dealt with target-specific intrinsics for a long time,
since its fix-point iteration is arguably the right place to do so. A
downside is that there's a pull to add an increasing amount of code
into lib/Transforms/InstCombine/ that really is target-specific.

What the aforementioned change does is provide a target hook via
TargetTransformInfo, and move the handling of all target intrinsics
for InstCombine purposes into the corresponding lib/Target/$foo/
directory via the hook, thus cleaning up the core of InstCombine.

Cheers,
Nicolai
--
Lerne, wie die Welt wirklich ist,
aber vergiss niemals, wie sie sein sollte.
_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

Johannes Doerfert via llvm-dev

unread,
Jun 29, 2020, 7:49:47 PM6/29/20
to Nicolai Hähnle, llvm-dev
+1

On 6/29/20 7:29 AM, Nicolai Hähnle via llvm-dev wrote:
> Hello,
>
> this mail is to raise awareness of https://reviews.llvm.org/D81728,
> which is substantial enough of a conceptual change that it should
> probably at least be mentioned in llvm-dev.
>
> InstCombine has dealt with target-specific intrinsics for a long time,
> since its fix-point iteration is arguably the right place to do so. A
> downside is that there's a pull to add an increasing amount of code
> into lib/Transforms/InstCombine/ that really is target-specific.
>
> What the aforementioned change does is provide a target hook via
> TargetTransformInfo, and move the handling of all target intrinsics
> for InstCombine purposes into the corresponding lib/Target/$foo/
> directory via the hook, thus cleaning up the core of InstCombine.
>
> Cheers,
> Nicolai

Hal Finkel via llvm-dev

unread,
Jun 29, 2020, 10:55:07 PM6/29/20
to Nicolai Hähnle, llvm-dev

On 6/29/20 7:29 AM, Nicolai Hähnle via llvm-dev wrote:
> Hello,
>
> this mail is to raise awareness of https://reviews.llvm.org/D81728,
> which is substantial enough of a conceptual change that it should
> probably at least be mentioned in llvm-dev.
>
> InstCombine has dealt with target-specific intrinsics for a long time,
> since its fix-point iteration is arguably the right place to do so. A
> downside is that there's a pull to add an increasing amount of code
> into lib/Transforms/InstCombine/ that really is target-specific.
>
> What the aforementioned change does is provide a target hook via
> TargetTransformInfo, and move the handling of all target intrinsics
> for InstCombine purposes into the corresponding lib/Target/$foo/
> directory via the hook, thus cleaning up the core of InstCombine.
>
> Cheers,
> Nicolai


I said this on the review, but to repeat it here, I think that this is a
good idea. We should allow targets to customize the behavior of the
optimizer with respect to target-specific intrinsics using code in the
target, not code spread throughout the optimizer. We now do this kind of
thing using TTI in many other places, and we should do it here too.

 -Hal


--
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory

David Greene via llvm-dev

unread,
Jun 30, 2020, 12:15:18 PM6/30/20
to Nicolai Hähnle, llvm-dev
Nicolai Hähnle via llvm-dev <llvm...@lists.llvm.org> writes:

> InstCombine has dealt with target-specific intrinsics for a long time,
> since its fix-point iteration is arguably the right place to do so. A
> downside is that there's a pull to add an increasing amount of code
> into lib/Transforms/InstCombine/ that really is target-specific.
>
> What the aforementioned change does is provide a target hook via
> TargetTransformInfo, and move the handling of all target intrinsics
> for InstCombine purposes into the corresponding lib/Target/$foo/
> directory via the hook, thus cleaning up the core of InstCombine.

+1. This is great! I hope to see more such target optimizer hooks in
the future.

-David

Chris Lattner via llvm-dev

unread,
Jun 30, 2020, 4:25:57 PM6/30/20
to David Greene, llvm-dev
I agree this is a great direction. I have some concerns about the details of the patch (added to the patch) but I agree this is a great direction to go. You might want to check out the MLIR canonicalize pass which is effectively this but factored in a more flexible way.

-Chris

Philip Reames via llvm-dev

unread,
Jul 1, 2020, 1:14:09 PM7/1/20
to Nicolai Hähnle, llvm-dev
Definite +1 on the general direction.

Philip

On 6/29/20 5:29 AM, Nicolai Hähnle via llvm-dev wrote:
> Hello,
>
> this mail is to raise awareness of https://reviews.llvm.org/D81728,
> which is substantial enough of a conceptual change that it should
> probably at least be mentioned in llvm-dev.
>
> InstCombine has dealt with target-specific intrinsics for a long time,
> since its fix-point iteration is arguably the right place to do so. A
> downside is that there's a pull to add an increasing amount of code
> into lib/Transforms/InstCombine/ that really is target-specific.
>
> What the aforementioned change does is provide a target hook via
> TargetTransformInfo, and move the handling of all target intrinsics
> for InstCombine purposes into the corresponding lib/Target/$foo/
> directory via the hook, thus cleaning up the core of InstCombine.
>
> Cheers,
> Nicolai

Reply all
Reply to author
Forward
0 new messages