1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00

Constant fold llvm.sqrt

llvm-svn: 23487
This commit is contained in:
Chris Lattner 2005-09-28 01:34:32 +00:00
parent cd79ed877a
commit 6ce1d7dabb

View File

@ -240,7 +240,9 @@ bool llvm::canConstantFoldCallTo(Function *F) {
const std::string &Name = F->getName(); const std::string &Name = F->getName();
switch (F->getIntrinsicID()) { switch (F->getIntrinsicID()) {
case Intrinsic::isunordered: return true; case Intrinsic::isunordered:
case Intrinsic::sqrt:
return true;
default: break; default: break;
} }
@ -321,6 +323,12 @@ Constant *llvm::ConstantFoldCall(Function *F,
return ConstantFP::get(Ty, log(V)); return ConstantFP::get(Ty, log(V));
else if (Name == "log10" && V > 0) else if (Name == "log10" && V > 0)
return ConstantFoldFP(log10, V, Ty); return ConstantFoldFP(log10, V, Ty);
else if (Name == "llvm.sqrt") {
if (V >= -0.0)
return ConstantFP::get(Ty, sqrt(V));
else // Undefined
return ConstantFP::get(Ty, 0.0);
}
break; break;
case 's': case 's':
if (Name == "sin") if (Name == "sin")