Skip to content

Commit 1aa96a2

Browse files
committed
Add fast-math.
1 parent cf60110 commit 1aa96a2

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

Source/Runtime/LLVMEmitIR.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,12 @@ namespace LLVMJIT
122122
, functionInstance(inFunctionInstance)
123123
, llvmFunction(inLLVMFunction)
124124
, irBuilder(context)
125-
{}
125+
{
126+
// SL : fast-math a IR level
127+
llvm::FastMathFlags FMF;
128+
FMF.setUnsafeAlgebra();
129+
irBuilder.setFastMathFlags(FMF);
130+
}
126131

127132
void emit();
128133

@@ -776,6 +781,8 @@ namespace LLVMJIT
776781
//
777782
// Load/store operators
778783
//
784+
785+
// SL : removed setVolatile
779786

780787
#define EMIT_LOAD_OP(valueTypeId,name,llvmMemoryType,naturalAlignmentLog2,conversionOp) \
781788
void valueTypeId##_##name(LoadOrStoreImm<naturalAlignmentLog2> imm) \

Source/Runtime/LLVMJIT.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,19 @@ namespace LLVMJIT
752752
// our symbols can't be found in the JITed object file.
753753
targetTriple += "-elf";
754754
#endif
755-
targetMachine = llvm::EngineBuilder().selectTarget(
755+
756+
// SL : fast-math a native level
757+
llvm::TargetOptions targetOptions;
758+
759+
targetOptions.AllowFPOpFusion = llvm::FPOpFusion::Fast;
760+
targetOptions.UnsafeFPMath = true;
761+
targetOptions.NoInfsFPMath = true;
762+
targetOptions.NoNaNsFPMath = true;
763+
targetOptions.GuaranteedTailCallOpt = true;
764+
targetOptions.NoTrappingFPMath = true;
765+
targetOptions.FPDenormalMode = llvm::FPDenormal::IEEE;
766+
767+
targetMachine = llvm::EngineBuilder().setTargetOptions(targetOptions).selectTarget(
756768
llvm::Triple(targetTriple),"",llvm::sys::getHostCPUName(),
757769
#if defined(_WIN32) && !defined(_WIN64)
758770
// Use SSE2 instead of the FPU on x86 for more control over how intermediate results are rounded.

0 commit comments

Comments
 (0)