Skip to content

Commit

Permalink
Add fast-math.
Browse files Browse the repository at this point in the history
  • Loading branch information
sletz committed Sep 9, 2017
1 parent cf60110 commit 1aa96a2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
9 changes: 8 additions & 1 deletion Source/Runtime/LLVMEmitIR.cpp
Expand Up @@ -122,7 +122,12 @@ namespace LLVMJIT
, functionInstance(inFunctionInstance) , functionInstance(inFunctionInstance)
, llvmFunction(inLLVMFunction) , llvmFunction(inLLVMFunction)
, irBuilder(context) , irBuilder(context)
{} {
// SL : fast-math a IR level
llvm::FastMathFlags FMF;
FMF.setUnsafeAlgebra();
irBuilder.setFastMathFlags(FMF);
}


void emit(); void emit();


Expand Down Expand Up @@ -776,6 +781,8 @@ namespace LLVMJIT
// //
// Load/store operators // Load/store operators
// //

// SL : removed setVolatile


#define EMIT_LOAD_OP(valueTypeId,name,llvmMemoryType,naturalAlignmentLog2,conversionOp) \ #define EMIT_LOAD_OP(valueTypeId,name,llvmMemoryType,naturalAlignmentLog2,conversionOp) \
void valueTypeId##_##name(LoadOrStoreImm<naturalAlignmentLog2> imm) \ void valueTypeId##_##name(LoadOrStoreImm<naturalAlignmentLog2> imm) \
Expand Down
14 changes: 13 additions & 1 deletion Source/Runtime/LLVMJIT.cpp
Expand Up @@ -752,7 +752,19 @@ namespace LLVMJIT
// our symbols can't be found in the JITed object file. // our symbols can't be found in the JITed object file.
targetTriple += "-elf"; targetTriple += "-elf";
#endif #endif
targetMachine = llvm::EngineBuilder().selectTarget(
// SL : fast-math a native level
llvm::TargetOptions targetOptions;

targetOptions.AllowFPOpFusion = llvm::FPOpFusion::Fast;
targetOptions.UnsafeFPMath = true;
targetOptions.NoInfsFPMath = true;
targetOptions.NoNaNsFPMath = true;
targetOptions.GuaranteedTailCallOpt = true;
targetOptions.NoTrappingFPMath = true;
targetOptions.FPDenormalMode = llvm::FPDenormal::IEEE;

targetMachine = llvm::EngineBuilder().setTargetOptions(targetOptions).selectTarget(
llvm::Triple(targetTriple),"",llvm::sys::getHostCPUName(), llvm::Triple(targetTriple),"",llvm::sys::getHostCPUName(),
#if defined(_WIN32) && !defined(_WIN64) #if defined(_WIN32) && !defined(_WIN64)
// Use SSE2 instead of the FPU on x86 for more control over how intermediate results are rounded. // Use SSE2 instead of the FPU on x86 for more control over how intermediate results are rounded.
Expand Down

0 comments on commit 1aa96a2

Please sign in to comment.