aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/Scalar/SimplifyLibCalls.cpp20
-rw-r--r--lib/Transforms/Utils/SimplifyLibCalls.cpp17
2 files changed, 17 insertions, 20 deletions
diff --git a/lib/Transforms/Scalar/SimplifyLibCalls.cpp b/lib/Transforms/Scalar/SimplifyLibCalls.cpp
index 8ae00d8b3a..64384debf6 100644
--- a/lib/Transforms/Scalar/SimplifyLibCalls.cpp
+++ b/lib/Transforms/Scalar/SimplifyLibCalls.cpp
@@ -100,24 +100,6 @@ namespace {
//===----------------------------------------------------------------------===//
//===---------------------------------------===//
-// 'isascii' Optimizations
-
-struct IsAsciiOpt : public LibCallOptimization {
- virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
- FunctionType *FT = Callee->getFunctionType();
- // We require integer(i32)
- if (FT->getNumParams() != 1 || !FT->getReturnType()->isIntegerTy() ||
- !FT->getParamType(0)->isIntegerTy(32))
- return 0;
-
- // isascii(c) -> c <u 128
- Value *Op = CI->getArgOperand(0);
- Op = B.CreateICmpULT(Op, B.getInt32(128), "isascii");
- return B.CreateZExt(Op, CI->getType());
- }
-};
-
-//===---------------------------------------===//
// 'toascii' Optimizations
struct ToAsciiOpt : public LibCallOptimization {
@@ -502,7 +484,6 @@ namespace {
StringMap<LibCallOptimization*> Optimizations;
// Integer Optimizations
- IsAsciiOpt IsAscii;
ToAsciiOpt ToAscii;
// Formatting and IO Optimizations
SPrintFOpt SPrintF; PrintFOpt PrintF;
@@ -563,7 +544,6 @@ void SimplifyLibCalls::AddOpt(LibFunc::Func F1, LibFunc::Func F2,
/// we know.
void SimplifyLibCalls::InitOptimizations() {
// Integer Optimizations
- Optimizations["isascii"] = &IsAscii;
Optimizations["toascii"] = &ToAscii;
// Formatting and IO Optimizations
diff --git a/lib/Transforms/Utils/SimplifyLibCalls.cpp b/lib/Transforms/Utils/SimplifyLibCalls.cpp
index 1320f70097..2b390c191c 100644
--- a/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ b/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -1283,6 +1283,21 @@ struct IsDigitOpt : public LibCallOptimization {
}
};
+struct IsAsciiOpt : public LibCallOptimization {
+ virtual Value *callOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
+ FunctionType *FT = Callee->getFunctionType();
+ // We require integer(i32)
+ if (FT->getNumParams() != 1 || !FT->getReturnType()->isIntegerTy() ||
+ !FT->getParamType(0)->isIntegerTy(32))
+ return 0;
+
+ // isascii(c) -> c <u 128
+ Value *Op = CI->getArgOperand(0);
+ Op = B.CreateICmpULT(Op, B.getInt32(128), "isascii");
+ return B.CreateZExt(Op, CI->getType());
+ }
+};
+
} // End anonymous namespace.
namespace llvm {
@@ -1333,6 +1348,7 @@ class LibCallSimplifierImpl {
FFSOpt FFS;
AbsOpt Abs;
IsDigitOpt IsDigit;
+ IsAsciiOpt IsAscii;
void initOptimizations();
void addOpt(LibFunc::Func F, LibCallOptimization* Opt);
@@ -1452,6 +1468,7 @@ void LibCallSimplifierImpl::initOptimizations() {
addOpt(LibFunc::labs, &Abs);
addOpt(LibFunc::llabs, &Abs);
addOpt(LibFunc::isdigit, &IsDigit);
+ addOpt(LibFunc::isascii, &IsAscii);
}
Value *LibCallSimplifierImpl::optimizeCall(CallInst *CI) {