[InstCombine] Fold abs of known negative operand
authorNikita Popov <nikita.ppv@gmail.com>
Sat, 5 Sep 2020 15:23:48 +0000 (17:23 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 8 Sep 2020 18:14:35 +0000 (20:14 +0200)
commite97f3b1b4327f9db0ca12cdd7157c304ad206802
tree5723c22a6c075932872630b41e04a5ec857432fe
parent59a467ee4faeee5b569960e53a76a0311d050d18
[InstCombine] Fold abs of known negative operand

If we know that the abs operand is known negative, we can replace
it with a neg.

To avoid computing known bits twice, I've removed the fold for the
non-negative case from InstSimplify. Both the non-negative and the
negative case are handled by InstCombine now, with one known bits call.

Differential Revision: https://reviews.llvm.org/D87196
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/test/Transforms/InstCombine/abs-intrinsic.ll
llvm/test/Transforms/InstSimplify/abs_intrinsic.ll