[InstCombine] try to narrow min/max intrinsics with constant operand
authorSanjay Patel <spatel@rotateright.com>
Mon, 1 Feb 2021 17:27:04 +0000 (12:27 -0500)
committerSanjay Patel <spatel@rotateright.com>
Mon, 1 Feb 2021 18:44:13 +0000 (13:44 -0500)
commit0ce2920f1707266c0d94dacc8719251b7b6a2c01
tree8b6df88f675793c9d7127653dcac8cb6469619fd
parentd23b68a8798913bda65db109e57029139197c587
[InstCombine] try to narrow min/max intrinsics with constant operand

The constant trunc/ext may not be the optimal pre-condition,
but I think that handles the common cases.

Example of Alive2 proof:
https://alive2.llvm.org/ce/z/sREeLC

This is another step towards canonicalizing to the intrinsics.
Narrowing was identified as source of potential regression for
abs(), so we need to handle this for min/max - see:
https://llvm.org/PR48816

If this is not enough, we could process intrinsics in
the trunc-driven matching in canEvaluateTruncated().
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/test/Transforms/InstCombine/minmax-intrinsics.ll