diff options
author | Chris Lattner <sabre@nondot.org> | 2010-09-07 20:01:38 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-09-07 20:01:38 +0000 |
commit | 6e27b3e0041802907194e6e4a00ac038d603759f (patch) | |
tree | 0e295f429fa43dea5e9106c0b53956c925cbbf80 /llvm/lib/Transforms | |
parent | 5444b36e014d7d518b832a9e41153487d53b358a (diff) | |
download | bcm5719-llvm-6e27b3e0041802907194e6e4a00ac038d603759f.tar.gz bcm5719-llvm-6e27b3e0041802907194e6e4a00ac038d603759f.zip |
Fix a serious performance regression introduced by r108687 on linux:
turning (fptrunc (sqrt (fpext x))) -> (sqrtf x) is great, but we have
to delete the original sqrt as well. Not doing so causes us to do
two sqrt's when building with -fmath-errno (the default on linux).
llvm-svn: 113260
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp index 6c2477d52c7..79a9b09c64d 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp @@ -1139,7 +1139,7 @@ Instruction *InstCombiner::visitFPTrunc(FPTruncInst &CI) { Arg->getOperand(0)->getType()->isFloatTy()) { Function *Callee = Call->getCalledFunction(); Module *M = CI.getParent()->getParent()->getParent(); - Constant* SqrtfFunc = M->getOrInsertFunction("sqrtf", + Constant *SqrtfFunc = M->getOrInsertFunction("sqrtf", Callee->getAttributes(), Builder->getFloatTy(), Builder->getFloatTy(), @@ -1147,6 +1147,11 @@ Instruction *InstCombiner::visitFPTrunc(FPTruncInst &CI) { CallInst *ret = CallInst::Create(SqrtfFunc, Arg->getOperand(0), "sqrtfcall"); ret->setAttributes(Callee->getAttributes()); + + + // Remove the old Call. With -fmath-errno, it won't get marked readnone. + Call->replaceAllUsesWith(UndefValue::get(Call->getType())); + EraseInstFromFunction(*Call); return ret; } } |