mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
1. Don't call Value::getName(), which is slow.
2. Lower calls to fabs and friends to FABS nodes etc unless the function has internal linkage. Before we wouldn't lower if it had a definition, which is incorrect. This allows us to compile: define double @fabs(double %f) { %tmp2 = tail call double @fabs( double %f ) ret double %tmp2 } into: _fabs: fabs f1, f1 blr git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41805 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8d9455d4e4
commit
87b51bc2b0
@ -2969,14 +2969,22 @@ void SelectionDAGLowering::LowerCallTo(Instruction &I,
|
||||
void SelectionDAGLowering::visitCall(CallInst &I) {
|
||||
const char *RenameFn = 0;
|
||||
if (Function *F = I.getCalledFunction()) {
|
||||
if (F->isDeclaration())
|
||||
if (F->isDeclaration()) {
|
||||
if (unsigned IID = F->getIntrinsicID()) {
|
||||
RenameFn = visitIntrinsicCall(I, IID);
|
||||
if (!RenameFn)
|
||||
return;
|
||||
} else { // Not an LLVM intrinsic.
|
||||
const std::string &Name = F->getName();
|
||||
if (Name[0] == 'c' && (Name == "copysign" || Name == "copysignf")) {
|
||||
}
|
||||
}
|
||||
|
||||
// Check for well-known libc/libm calls. If the function is internal, it
|
||||
// can't be a library call.
|
||||
unsigned NameLen = F->getNameLen();
|
||||
if (!F->hasInternalLinkage() && NameLen) {
|
||||
const char *NameStr = F->getNameStart();
|
||||
if (NameStr[0] == 'c' &&
|
||||
((NameLen == 8 && !strcmp(NameStr, "copysign")) ||
|
||||
(NameLen == 9 && !strcmp(NameStr, "copysignf")))) {
|
||||
if (I.getNumOperands() == 3 && // Basic sanity checks.
|
||||
I.getOperand(1)->getType()->isFloatingPoint() &&
|
||||
I.getType() == I.getOperand(1)->getType() &&
|
||||
@ -2987,7 +2995,9 @@ void SelectionDAGLowering::visitCall(CallInst &I) {
|
||||
LHS, RHS));
|
||||
return;
|
||||
}
|
||||
} else if (Name[0] == 'f' && (Name == "fabs" || Name == "fabsf")) {
|
||||
} else if (NameStr[0] == 'f' &&
|
||||
((NameLen == 4 && !strcmp(NameStr, "fabs")) ||
|
||||
(NameLen == 5 && !strcmp(NameStr, "fabsf")))) {
|
||||
if (I.getNumOperands() == 2 && // Basic sanity checks.
|
||||
I.getOperand(1)->getType()->isFloatingPoint() &&
|
||||
I.getType() == I.getOperand(1)->getType()) {
|
||||
@ -2995,7 +3005,9 @@ void SelectionDAGLowering::visitCall(CallInst &I) {
|
||||
setValue(&I, DAG.getNode(ISD::FABS, Tmp.getValueType(), Tmp));
|
||||
return;
|
||||
}
|
||||
} else if (Name[0] == 's' && (Name == "sin" || Name == "sinf")) {
|
||||
} else if (NameStr[0] == 's' &&
|
||||
((NameLen == 3 && !strcmp(NameStr, "sin")) ||
|
||||
(NameLen == 4 && !strcmp(NameStr, "sinf")))) {
|
||||
if (I.getNumOperands() == 2 && // Basic sanity checks.
|
||||
I.getOperand(1)->getType()->isFloatingPoint() &&
|
||||
I.getType() == I.getOperand(1)->getType()) {
|
||||
@ -3003,7 +3015,9 @@ void SelectionDAGLowering::visitCall(CallInst &I) {
|
||||
setValue(&I, DAG.getNode(ISD::FSIN, Tmp.getValueType(), Tmp));
|
||||
return;
|
||||
}
|
||||
} else if (Name[0] == 'c' && (Name == "cos" || Name == "cosf")) {
|
||||
} else if (NameStr[0] == 'c' &&
|
||||
((NameLen == 3 && !strcmp(NameStr, "cos")) ||
|
||||
(NameLen == 4 && !strcmp(NameStr, "cosf")))) {
|
||||
if (I.getNumOperands() == 2 && // Basic sanity checks.
|
||||
I.getOperand(1)->getType()->isFloatingPoint() &&
|
||||
I.getType() == I.getOperand(1)->getType()) {
|
||||
|
Loading…
Reference in New Issue
Block a user