mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
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). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113260 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user