[CodeGen] Teach LLVM how to lower @llvm.{min,max}num to {MIN,MAX}NAN
authorDavid Majnemer <david.majnemer@gmail.com>
Thu, 14 Apr 2016 07:13:24 +0000 (07:13 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Thu, 14 Apr 2016 07:13:24 +0000 (07:13 +0000)
commit0f26b0aeb4a91418d4c273bb25ab22f3b416a960
treef4a1cfadf86bfb6a4a6aa20c9df02cea75ebfbef
parentd871531687b062862234a3346b50f1824e27ed3b
[CodeGen] Teach LLVM how to lower @llvm.{min,max}num to {MIN,MAX}NAN

The behavior of {MIN,MAX}NAN differs from that of {MIN,MAX}NUM when only
one of the inputs is NaN: -NUM will return the non-NaN argument while
-NAN would return NaN.

It is desirable to lower to @llvm.{min,max}num to -NAN if they don't
have a native instruction for -NUM.  Notably, ARMv7 NEON's vmin has the
-NAN semantics.

N.B.  Of course, it is only safe to do this if the intrinsic call is
marked nnan.

llvm-svn: 266279
llvm/include/llvm/Analysis/TargetTransformInfo.h
llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
llvm/include/llvm/CodeGen/BasicTTIImpl.h
llvm/lib/Analysis/CostModel.cpp
llvm/lib/Analysis/TargetTransformInfo.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/Transforms/Vectorize/BBVectorize.cpp
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/test/CodeGen/ARM/vminmax.ll