summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2016-01-19 18:38:52 +0000
committerSanjay Patel <spatel@rotateright.com>2016-01-19 18:38:52 +0000
commitd1f4f03f5e94e8581f3ed3e362a8d6260798ea0f (patch)
treea6044ae15cdfd2096be3be76e243965bc02b6f3a
parent0f6650e8e85fd280917b7534fd7eb41d209e6616 (diff)
downloadbcm5719-llvm-d1f4f03f5e94e8581f3ed3e362a8d6260798ea0f.tar.gz
bcm5719-llvm-d1f4f03f5e94e8581f3ed3e362a8d6260798ea0f.zip
[LibCallSimplifier] use instruction-level fast-math-flags to shrink calls
This is a continuation of adding FMF to call instructions: http://reviews.llvm.org/rL255555 llvm-svn: 258158
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp21
-rw-r--r--llvm/test/Transforms/InstCombine/double-float-shrink-1.ll38
2 files changed, 20 insertions, 39 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
index de9fb7c524f..c3100dd9cc3 100644
--- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -104,23 +104,6 @@ static bool hasUnaryFloatFn(const TargetLibraryInfo *TLI, Type *Ty,
}
}
-/// \brief Check whether we can use unsafe floating point math for
-/// the function passed as input.
-static bool canUseUnsafeFPMath(Function *F) {
-
- // FIXME: For finer-grain optimization, we need intrinsics to have the same
- // fast-math flag decorations that are applied to FP instructions. For now,
- // we have to rely on the function-level unsafe-fp-math attribute to do this
- // optimization because there's no other way to express that the call can be
- // relaxed.
- if (F->hasFnAttribute("unsafe-fp-math")) {
- Attribute Attr = F->getFnAttribute("unsafe-fp-math");
- if (Attr.getValueAsString() == "true")
- return true;
- }
- return false;
-}
-
/// \brief Returns whether \p F matches the signature expected for the
/// string/memory copying library function \p Func.
/// Acceptable functions are st[rp][n]?cpy, memove, memcpy, and memset.
@@ -2184,10 +2167,10 @@ Value *LibCallSimplifier::optimizeCall(CallInst *CI) {
IRBuilder<> Builder(CI, /*FPMathTag=*/nullptr, OpBundles);
bool isCallingConvC = CI->getCallingConv() == llvm::CallingConv::C;
- // Command-line parameter overrides function attribute.
+ // Command-line parameter overrides instruction attribute.
if (EnableUnsafeFPShrink.getNumOccurrences() > 0)
UnsafeFPShrink = EnableUnsafeFPShrink;
- else if (canUseUnsafeFPMath(Callee))
+ else if (isa<FPMathOperator>(CI) && CI->hasUnsafeAlgebra())
UnsafeFPShrink = true;
// First, check for intrinsics.
diff --git a/llvm/test/Transforms/InstCombine/double-float-shrink-1.ll b/llvm/test/Transforms/InstCombine/double-float-shrink-1.ll
index 319ea325983..d3dd0f6746b 100644
--- a/llvm/test/Transforms/InstCombine/double-float-shrink-1.ll
+++ b/llvm/test/Transforms/InstCombine/double-float-shrink-1.ll
@@ -366,30 +366,28 @@ define float @max1(float %a, float %b) {
declare double @fmax(double, double)
-declare double @tanh(double) #1
-declare double @tan(double) #1
+declare double @tanh(double)
+declare double @tan(double)
; sqrt is a special case: the shrinking optimization
; is valid even without unsafe-fp-math.
declare double @sqrt(double)
declare double @llvm.sqrt.f64(double)
-declare double @sin(double) #1
-declare double @log2(double) #1
-declare double @log1p(double) #1
-declare double @log10(double) #1
-declare double @log(double) #1
-declare double @logb(double) #1
-declare double @exp10(double) #1
-declare double @expm1(double) #1
-declare double @exp(double) #1
-declare double @cbrt(double) #1
-declare double @atanh(double) #1
-declare double @atan(double) #1
-declare double @acos(double) #1
-declare double @acosh(double) #1
-declare double @asin(double) #1
-declare double @asinh(double) #1
-
-attributes #1 = { "unsafe-fp-math"="true" }
+declare double @sin(double)
+declare double @log2(double)
+declare double @log1p(double)
+declare double @log10(double)
+declare double @log(double)
+declare double @logb(double)
+declare double @exp10(double)
+declare double @expm1(double)
+declare double @exp(double)
+declare double @cbrt(double)
+declare double @atanh(double)
+declare double @atan(double)
+declare double @acos(double)
+declare double @acosh(double)
+declare double @asin(double)
+declare double @asinh(double)
OpenPOWER on IntegriCloud