summaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/SimplifyLibCalls.cpp
diff options
context:
space:
mode:
authorMeador Inge <meadori@codesourcery.com>2012-11-26 00:24:07 +0000
committerMeador Inge <meadori@codesourcery.com>2012-11-26 00:24:07 +0000
commitdfb3b1a779c62c1ee41f9cddcaad0b89278052ae (patch)
tree809db6e0fb93be4b0f656268dd396aa9ef419334 /lib/Transforms/Scalar/SimplifyLibCalls.cpp
parent15d099a790f3fd6f8f643c4e7c50a1659f4fc92b (diff)
downloadllvm-dfb3b1a779c62c1ee41f9cddcaad0b89278052ae.tar.gz
llvm-dfb3b1a779c62c1ee41f9cddcaad0b89278052ae.tar.bz2
llvm-dfb3b1a779c62c1ee41f9cddcaad0b89278052ae.tar.xz
instcombine: Migrate *abs optimizations
This patch migrates the *abs optimizations from the simplify-libcalls pass into the instcombine library call simplifier. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168574 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/SimplifyLibCalls.cpp')
-rw-r--r--lib/Transforms/Scalar/SimplifyLibCalls.cpp26
1 files changed, 1 insertions, 25 deletions
diff --git a/lib/Transforms/Scalar/SimplifyLibCalls.cpp b/lib/Transforms/Scalar/SimplifyLibCalls.cpp
index fbfb7b42c9..fecc389307 100644
--- a/lib/Transforms/Scalar/SimplifyLibCalls.cpp
+++ b/lib/Transforms/Scalar/SimplifyLibCalls.cpp
@@ -137,27 +137,6 @@ struct IsAsciiOpt : public LibCallOptimization {
};
//===---------------------------------------===//
-// 'abs', 'labs', 'llabs' Optimizations
-
-struct AbsOpt : public LibCallOptimization {
- virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
- FunctionType *FT = Callee->getFunctionType();
- // We require integer(integer) where the types agree.
- if (FT->getNumParams() != 1 || !FT->getReturnType()->isIntegerTy() ||
- FT->getParamType(0) != FT->getReturnType())
- return 0;
-
- // abs(x) -> x >s -1 ? x : -x
- Value *Op = CI->getArgOperand(0);
- Value *Pos = B.CreateICmpSGT(Op, Constant::getAllOnesValue(Op->getType()),
- "ispos");
- Value *Neg = B.CreateNeg(Op, "neg");
- return B.CreateSelect(Pos, Op, Neg);
- }
-};
-
-
-//===---------------------------------------===//
// 'toascii' Optimizations
struct ToAsciiOpt : public LibCallOptimization {
@@ -542,7 +521,7 @@ namespace {
StringMap<LibCallOptimization*> Optimizations;
// Integer Optimizations
- AbsOpt Abs; IsDigitOpt IsDigit; IsAsciiOpt IsAscii;
+ IsDigitOpt IsDigit; IsAsciiOpt IsAscii;
ToAsciiOpt ToAscii;
// Formatting and IO Optimizations
SPrintFOpt SPrintF; PrintFOpt PrintF;
@@ -603,9 +582,6 @@ void SimplifyLibCalls::AddOpt(LibFunc::Func F1, LibFunc::Func F2,
/// we know.
void SimplifyLibCalls::InitOptimizations() {
// Integer Optimizations
- Optimizations["abs"] = &Abs;
- Optimizations["labs"] = &Abs;
- Optimizations["llabs"] = &Abs;
Optimizations["isdigit"] = &IsDigit;
Optimizations["isascii"] = &IsAscii;
Optimizations["toascii"] = &ToAscii;