diff options
| author | Chris Lattner <sabre@nondot.org> | 2005-09-29 06:17:27 +0000 | 
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2005-09-29 06:17:27 +0000 | 
| commit | 87ef943a4cc8c179350d0b3087dd924ac0723d02 (patch) | |
| tree | 10383aca1b36ee4bfbc1fadca29cae0894cfd357 /llvm/lib/Transforms | |
| parent | 5de939e79114ac471fdf2f5a1c1eb9269d48b1bd (diff) | |
| download | bcm5719-llvm-87ef943a4cc8c179350d0b3087dd924ac0723d02.tar.gz bcm5719-llvm-87ef943a4cc8c179350d0b3087dd924ac0723d02.zip | |
Fold isascii into a simple comparison.  This speeds up 197.parser by 7.4%,
bringing the LLC time down to the CBE time.
llvm-svn: 23521
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp | 26 | 
1 files changed, 26 insertions, 0 deletions
| diff --git a/llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp b/llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp index c3075f4eaa1..58aac20b70a 100644 --- a/llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp +++ b/llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp @@ -1745,6 +1745,32 @@ public:    }  } isdigitOptimizer; +struct isasciiOptimization : public LibCallOptimization { +public: +  isasciiOptimization() +    : LibCallOptimization("isascii", "Number of 'isascii' calls simplified") {} +   +  virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){ +    return F->arg_size() == 1 && F->arg_begin()->getType()->isInteger() &&  +           F->getReturnType()->isInteger(); +  } +   +  /// @brief Perform the isascii optimization. +  virtual bool OptimizeCall(CallInst *CI, SimplifyLibCalls &SLC) { +    // isascii(c)   -> (unsigned)c < 128 +    Value *V = CI->getOperand(1); +    if (V->getType()->isSigned()) +      V = new CastInst(V, V->getType()->getUnsignedVersion(), V->getName(), CI); +    Value *Cmp = BinaryOperator::createSetLT(V, ConstantUInt::get(V->getType(), +                                                                  128), +                                             V->getName()+".isascii", CI); +    if (Cmp->getType() != CI->getType()) +      Cmp = new CastInst(Cmp, CI->getType(), Cmp->getName(), CI); +    CI->replaceAllUsesWith(Cmp); +    CI->eraseFromParent(); +    return true; +  } +} isasciiOptimizer;  /// This LibCallOptimization will simplify calls to the "toascii" library | 

