diff options
author | Ruiling Song <ruiling.song@intel.com> | 2015-02-28 13:44:05 +0800 |
---|---|---|
committer | Zhigang Gong <zhigang.gong@intel.com> | 2015-02-28 13:41:24 +0800 |
commit | 65780d81c786def2f44c11b8d6f5e4895c5061bb (patch) | |
tree | abbd7c40f09630ed0b36c0632d2febfe3f7b355f | |
parent | ae1980ab6a0817e3bd51a47685b727173f29bd4b (diff) |
GBE: Fix fast-math issue under llvm 3.6.
"__ocl_math_fastpath_flag" was directly optimized out when compiling libocl under llvm 3.6
And set its initialization value after loading libocl.
Signed-off-by: Ruiling Song <ruiling.song@intel.com>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
-rw-r--r-- | backend/src/libocl/tmpl/ocl_math.tmpl.cl | 2 | ||||
-rw-r--r-- | backend/src/llvm/llvm_bitcode_link.cpp | 10 |
2 files changed, 5 insertions, 7 deletions
diff --git a/backend/src/libocl/tmpl/ocl_math.tmpl.cl b/backend/src/libocl/tmpl/ocl_math.tmpl.cl index 49c4efa5..fcc60fd7 100644 --- a/backend/src/libocl/tmpl/ocl_math.tmpl.cl +++ b/backend/src/libocl/tmpl/ocl_math.tmpl.cl @@ -21,7 +21,7 @@ #include "ocl_common.h" #include "ocl_integer.h" -constant int __ocl_math_fastpath_flag = 1; +extern constant int __ocl_math_fastpath_flag; PURE CONST float __gen_ocl_fabs(float x); PURE CONST float __gen_ocl_sin(float x); diff --git a/backend/src/llvm/llvm_bitcode_link.cpp b/backend/src/llvm/llvm_bitcode_link.cpp index 61e2ea15..96f77810 100644 --- a/backend/src/llvm/llvm_bitcode_link.cpp +++ b/backend/src/llvm/llvm_bitcode_link.cpp @@ -73,12 +73,10 @@ namespace gbe return NULL; } - if (strictMath) { - llvm::GlobalVariable* mathFastFlag = oclLib->getGlobalVariable("__ocl_math_fastpath_flag"); - assert(mathFastFlag); - Type* intTy = IntegerType::get(ctx, 32); - mathFastFlag->setInitializer(ConstantInt::get(intTy, 0)); - } + llvm::GlobalVariable* mathFastFlag = oclLib->getGlobalVariable("__ocl_math_fastpath_flag"); + assert(mathFastFlag); + Type* intTy = IntegerType::get(ctx, 32); + mathFastFlag->setInitializer(ConstantInt::get(intTy, strictMath ? 0 : 1)); return oclLib; } |