mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-16 12:24:03 +00:00
Constant fold the isnan intrinsic
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14150 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -15,6 +15,7 @@
|
|||||||
#include "llvm/Transforms/Utils/Local.h"
|
#include "llvm/Transforms/Utils/Local.h"
|
||||||
#include "llvm/Constants.h"
|
#include "llvm/Constants.h"
|
||||||
#include "llvm/Instructions.h"
|
#include "llvm/Instructions.h"
|
||||||
|
#include "llvm/Intrinsics.h"
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
@ -234,6 +235,12 @@ bool llvm::ConstantFoldTerminator(BasicBlock *BB) {
|
|||||||
/// the specified function.
|
/// the specified function.
|
||||||
bool llvm::canConstantFoldCallTo(Function *F) {
|
bool llvm::canConstantFoldCallTo(Function *F) {
|
||||||
const std::string &Name = F->getName();
|
const std::string &Name = F->getName();
|
||||||
|
|
||||||
|
switch (F->getIntrinsicID()) {
|
||||||
|
case Intrinsic::isnan: return true;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
return Name == "sin" || Name == "cos" || Name == "tan" || Name == "sqrt" ||
|
return Name == "sin" || Name == "cos" || Name == "tan" || Name == "sqrt" ||
|
||||||
Name == "log" || Name == "log10" || Name == "exp" || Name == "pow" ||
|
Name == "log" || Name == "log10" || Name == "exp" || Name == "pow" ||
|
||||||
Name == "acos" || Name == "asin" || Name == "atan" || Name == "fmod";
|
Name == "acos" || Name == "asin" || Name == "atan" || Name == "fmod";
|
||||||
@ -258,7 +265,9 @@ Constant *llvm::ConstantFoldCall(Function *F,
|
|||||||
if (Operands.size() == 1) {
|
if (Operands.size() == 1) {
|
||||||
if (ConstantFP *Op = dyn_cast<ConstantFP>(Operands[0])) {
|
if (ConstantFP *Op = dyn_cast<ConstantFP>(Operands[0])) {
|
||||||
double V = Op->getValue();
|
double V = Op->getValue();
|
||||||
if (Name == "sin")
|
if (Name == "llvm.isnan")
|
||||||
|
return ConstantBool::get(isnan(V));
|
||||||
|
else if (Name == "sin")
|
||||||
return ConstantFP::get(Ty, sin(V));
|
return ConstantFP::get(Ty, sin(V));
|
||||||
else if (Name == "cos")
|
else if (Name == "cos")
|
||||||
return ConstantFP::get(Ty, cos(V));
|
return ConstantFP::get(Ty, cos(V));
|
||||||
|
Reference in New Issue
Block a user