Add support for floating-point minnum and maxnum
authorJames Molloy <james.molloy@arm.com>
Tue, 11 Aug 2015 09:12:57 +0000 (09:12 +0000)
committerJames Molloy <james.molloy@arm.com>
Tue, 11 Aug 2015 09:12:57 +0000 (09:12 +0000)
commit134bec27226ab1d37cff44b04cef73b67321601b
tree694344ed69bba87532061b2dcfcdae634aee2dd6
parent1c78ca6a09cec862d6aad04e820dae98b71be9fc
Add support for floating-point minnum and maxnum

The select pattern recognition in ValueTracking (as used by InstCombine
and SelectionDAGBuilder) only knew about integer patterns. This teaches
it about minimum and maximum operations.

matchSelectPattern() has been extended to return a struct containing the
existing Flavor and a new enum defining the pattern's behavior when
given one NaN operand.

C minnum() is defined to return the non-NaN operand in this case, but
the idiomatic C "a < b ? a : b" would return the NaN operand.

ARM and AArch64 at least have different instructions for these different cases.

llvm-svn: 244580
llvm/include/llvm/Analysis/ValueTracking.h
llvm/lib/Analysis/ValueTracking.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
llvm/test/Transforms/InstCombine/minmax-fp.ll [new file with mode: 0644]
llvm/unittests/Analysis/CMakeLists.txt
llvm/unittests/Analysis/ValueTrackingTest.cpp [new file with mode: 0644]