[llvm-commits] CVS: llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp
Chris Lattner
lattner at cs.uiuc.edu
Wed Sep 28 23:17:39 PDT 2005
Changes in directory llvm/lib/Transforms/IPO:
SimplifyLibCalls.cpp updated: 1.53 -> 1.54
---
Log message:
Fold isascii into a simple comparison. This speeds up 197.parser by 7.4%,
bringing the LLC time down to the CBE time.
---
Diffs of the changes: (+26 -0)
SimplifyLibCalls.cpp | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+)
Index: llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp
diff -u llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp:1.53 llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp:1.54
--- llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp:1.53 Thu Sep 29 01:16:11 2005
+++ llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp Thu Sep 29 01:17:27 2005
@@ -1745,6 +1745,32 @@
}
} 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
More information about the llvm-commits
mailing list