mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-21 08:17:40 +00:00
instcombine: Migrate isascii optimizations
This patch migrates the isascii optimizations from the simplify-libcalls pass into the instcombine library call simplifier. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168579 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user