Lower this to LLVM's sqrt intrinsic, which on x64 turns into an SSE2 sqrt instruction.
This commit is contained in:
Andy Ayers 2015-04-20 08:31:15 -07:00
Родитель dbd11eda17
Коммит f8771e9082
3 изменённых файлов: 24 добавлений и 5 удалений

Просмотреть файл

@ -2894,7 +2894,13 @@ public:
virtual void storeStaticField(CORINFO_RESOLVED_TOKEN *FieldToken, virtual void storeStaticField(CORINFO_RESOLVED_TOKEN *FieldToken,
IRNode *ValueToStore, bool IsVolatile) = 0; IRNode *ValueToStore, bool IsVolatile) = 0;
virtual IRNode *stringGetChar(IRNode *Arg1, IRNode *Arg2) = 0; virtual IRNode *stringGetChar(IRNode *Arg1, IRNode *Arg2) = 0;
virtual bool sqrt(IRNode *Arg1, IRNode **RetVal) = 0;
/// Optionally generate inline code for the \p sqrt operation
///
/// \param Argument input value for sqrt
/// \param Result [out] resulting sqrt value, iff reader decided to expand
/// \returns true iff Result represents the sqrt
virtual bool sqrt(IRNode *Argument, IRNode **Result) = 0;
virtual bool interlockedIntrinsicBinOp(IRNode *Arg1, IRNode *Arg2, virtual bool interlockedIntrinsicBinOp(IRNode *Arg1, IRNode *Arg2,
IRNode **RetVal, IRNode **RetVal,

Просмотреть файл

@ -458,10 +458,7 @@ public:
IRNode *ValueToStore, bool IsVolatile) override; IRNode *ValueToStore, bool IsVolatile) override;
IRNode *stringGetChar(IRNode *Arg1, IRNode *Arg2) override; IRNode *stringGetChar(IRNode *Arg1, IRNode *Arg2) override;
bool sqrt(IRNode *Argument, IRNode **Result) override;
bool sqrt(IRNode *Arg1, IRNode **RetVal) override {
throw NotYetImplementedException("sqrt");
};
// The callTarget node is only required on IA64. // The callTarget node is only required on IA64.
bool interlockedIntrinsicBinOp(IRNode *Arg1, IRNode *Arg2, IRNode **RetVal, bool interlockedIntrinsicBinOp(IRNode *Arg1, IRNode *Arg2, IRNode **RetVal,

Просмотреть файл

@ -5479,6 +5479,22 @@ bool GenIR::abs(IRNode *Argument, IRNode **Result) {
return false; return false;
} }
bool GenIR::sqrt(IRNode *Argument, IRNode **Result) {
Type *Ty = Argument->getType();
if (Ty->isFloatingPointTy()) {
Type *Types[] = {Ty};
Value *FSqrt = Intrinsic::getDeclaration(JitContext->CurrentModule,
Intrinsic::sqrt, Types);
bool MayThrow = false;
Value *Sqrt = makeCall(FSqrt, MayThrow, Argument).getInstruction();
*Result = (IRNode *)Sqrt;
return true;
}
return false;
}
IRNode *GenIR::localAlloc(IRNode *Arg, bool ZeroInit) { IRNode *GenIR::localAlloc(IRNode *Arg, bool ZeroInit) {
// Note that we've seen a localloc in this method, since it has repercussions // Note that we've seen a localloc in this method, since it has repercussions
// on other aspects of code generation. // on other aspects of code generation.