Add support for floating-point minnum and maxnum
commitcd45f4f580806fc29ff698bf6df01e2994e211de
authorJames Molloy <james.molloy@arm.com>
Tue, 11 Aug 2015 09:12:57 +0000 (11 09:12 +0000)
committerJames Molloy <james.molloy@arm.com>
Tue, 11 Aug 2015 09:12:57 +0000 (11 09:12 +0000)
tree064495893d4c0114d5b36d1235f5aa84595a2237
parente7b9d6cf4548f09973f4b31bda2d775e0d6fd631
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244580 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Analysis/ValueTracking.h
lib/Analysis/ValueTracking.cpp
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
lib/Transforms/InstCombine/InstCombineCasts.cpp
lib/Transforms/InstCombine/InstCombineSelect.cpp
lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
test/Transforms/InstCombine/minmax-fp.ll [new file with mode: 0644]
unittests/Analysis/CMakeLists.txt
unittests/Analysis/ValueTrackingTest.cpp [new file with mode: 0644]