Heads-up: Handling target-specific intrinsics in InstCombine

Hello,

this mail is to raise awareness of ⚙ D81728 [InstCombine] Add target-specific inst combining,
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

+1

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

Nicolai Hähnle via llvm-dev <llvm-dev@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

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

Definite +1 on the general direction.

Philip