[ValueTracking] Support signed intrinsic clamp
authorNikita Popov <npopov@redhat.com>
Wed, 23 Feb 2022 11:40:31 +0000 (12:40 +0100)
committerNikita Popov <npopov@redhat.com>
Wed, 23 Feb 2022 11:45:16 +0000 (12:45 +0100)
commit6777ec9e4df79d88f179593e20d6cb58a3effba4
tree14b5fa5c2f962420d1e8b220b93618ab1d78710d
parentd6e008089c2d758dabefe71ae7cf18e46928b5ef
[ValueTracking] Support signed intrinsic clamp

This is the same special logic we apply for SPF signed clamps
when computing the number of sign bits, just for intrinsics.

This just uses the same logic as the select case, but there's
multiple directions this could be improved in: We could also use
the num sign bits from the clamped value, we could do this during
constant range calculation, and there's probably unsigned analogues
for the constant range case at least.
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Transforms/InstCombine/max_known_bits.ll