mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-24 22:24:54 +00:00
Add support for sqrt, sqrtl, and sqrtf in TargetLibraryInfo. Disable
(fptrunc (sqrt (fpext x))) -> (sqrtf x) transformation if -fno-builtin is specified. rdar://10466410 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145460 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include "InstCombine.h"
|
||||
#include "llvm/Analysis/ConstantFolding.h"
|
||||
#include "llvm/Target/TargetData.h"
|
||||
#include "llvm/Target/TargetLibraryInfo.h"
|
||||
#include "llvm/Support/PatternMatch.h"
|
||||
using namespace llvm;
|
||||
using namespace PatternMatch;
|
||||
@@ -1213,10 +1214,10 @@ Instruction *InstCombiner::visitFPTrunc(FPTruncInst &CI) {
|
||||
}
|
||||
|
||||
// Fold (fptrunc (sqrt (fpext x))) -> (sqrtf x)
|
||||
// NOTE: This should be disabled by -fno-builtin-sqrt if we ever support it.
|
||||
const TargetLibraryInfo &TLI = getAnalysis<TargetLibraryInfo>();
|
||||
CallInst *Call = dyn_cast<CallInst>(CI.getOperand(0));
|
||||
if (Call && Call->getCalledFunction() &&
|
||||
Call->getCalledFunction()->getName() == "sqrt" &&
|
||||
if (Call && Call->getCalledFunction() && TLI.has(LibFunc::sqrtf) &&
|
||||
Call->getCalledFunction()->getName() == TLI.getName(LibFunc::sqrt) &&
|
||||
Call->getNumArgOperands() == 1 &&
|
||||
Call->hasOneUse()) {
|
||||
CastInst *Arg = dyn_cast<CastInst>(Call->getArgOperand(0));
|
||||
|
@@ -41,6 +41,7 @@
|
||||
#include "llvm/Analysis/InstructionSimplify.h"
|
||||
#include "llvm/Analysis/MemoryBuiltins.h"
|
||||
#include "llvm/Target/TargetData.h"
|
||||
#include "llvm/Target/TargetLibraryInfo.h"
|
||||
#include "llvm/Transforms/Utils/Local.h"
|
||||
#include "llvm/Support/CFG.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
@@ -79,6 +80,7 @@ INITIALIZE_PASS(InstCombiner, "instcombine",
|
||||
|
||||
void InstCombiner::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
AU.setPreservesCFG();
|
||||
AU.addRequired<TargetLibraryInfo>();
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user