Fold fcmp in cases where value is provably non-negative. By Arch Robison.
authorElena Demikhovsky <elena.demikhovsky@intel.com>
Wed, 28 Jan 2015 08:03:58 +0000 (08:03 +0000)
committerElena Demikhovsky <elena.demikhovsky@intel.com>
Wed, 28 Jan 2015 08:03:58 +0000 (08:03 +0000)
commitb5c82c079a50767a6734aa9683a705c75ae8bd00
treea7c6228b10dbbb2f91414d7b2e3ecf18098bb541
parente02ee8cf0598f96f0ddc2da637c2aaddc7c565db
Fold fcmp in cases where value is provably non-negative. By Arch Robison.

This patch folds fcmp in some cases of interest in Julia. The patch adds a function CannotBeOrderedLessThanZero that returns true if a value is provably not less than zero. I.e. the function returns true if the value is provably -0, +0, positive, or a NaN. The patch extends InstructionSimplify.cpp to fold instances of fcmp where:
 - the predicate is olt or uge
 - the first operand is provably not less than zero
 - the second operand is zero
The motivation for handling these cases optimizing away domain checks for sqrt in Julia for common idioms such as sqrt(x*x+y*y)..

http://reviews.llvm.org/D6972

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227298 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Analysis/ValueTracking.h
lib/Analysis/InstructionSimplify.cpp
lib/Analysis/ValueTracking.cpp
test/Transforms/InstSimplify/floating-point-compare.ll [new file with mode: 0644]