]> granicus.if.org Git - llvm/commit
[InstCombine] Canonicalize clamp of float types to minmax in fast mode.
authorNikolai Bozhenov <nikolai.bozhenov@intel.com>
Wed, 28 Jun 2017 09:26:20 +0000 (09:26 +0000)
committerNikolai Bozhenov <nikolai.bozhenov@intel.com>
Wed, 28 Jun 2017 09:26:20 +0000 (09:26 +0000)
commit5b91c92a71b5cccf6bbb9c49c2b6a710cde2797a
tree9bc140d4ea12b8072d051fb462bb753f7d92f0f6
parentcd701a9011045f477f73024cdeb299e6fb2b2f3c
[InstCombine] Canonicalize clamp of float types to minmax in fast mode.

Summary:
This commit allows matchSelectPattern to recognize clamp of float
arguments in the presence of FMF the same way as already done for
integers.

This case is a little different though. With integers, given the
min/max pattern is recognized, DAGBuilder starts selecting MIN/MAX
"automatically". That is not the case for float, because for them only
full FMINNAN/FMINNUM/FMAXNAN/FMAXNUM ISD nodes exist and they do care
about NaNs. On the other hand, some backends (e.g. X86) have only
FMIN/FMAX nodes that do not care about NaNS and the former NAN/NUM
nodes are illegal thus selection is not happening. So I decided to do
such kind of transformation in IR (InstCombiner) instead of
complicating the logic in the backend.

Reviewers: spatel, jmolloy, majnemer, efriedma, craig.topper

Reviewed By: efriedma

Subscribers: hiraditya, javed.absar, n.bozhenov, llvm-commits

Patch by Andrei Elovikov <andrei.elovikov@intel.com>

Differential Revision: https://reviews.llvm.org/D33186

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306525 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/IR/PatternMatch.h
lib/Analysis/ValueTracking.cpp
lib/Transforms/InstCombine/InstCombineSelect.cpp
test/Transforms/InstCombine/clamp-to-minmax.ll