[Beignet] [PATCH] enable FP_CONTRACT on as default, and implemented with MAD
Guo Yejun
yejun.guo at intel.com
Mon Feb 29 00:08:06 UTC 2016
According to OpenCL spec, FP_CONTRACT is on as default, while LLVM/clang
just enabled it at http://reviews.llvm.org/D14200 at Nov 2015. So we still
need set this option explicitly now.
The implementation is hardware MAD instruction whose accuracy is enough
for FP_CONTRACT.
Passed test: contractions of conformance test
Signed-off-by: Guo Yejun <yejun.guo at intel.com>
---
backend/src/backend/program.cpp | 2 +-
backend/src/llvm/llvm_gen_backend.cpp | 12 +-----------
backend/src/llvm/llvm_scalarize.cpp | 1 +
3 files changed, 3 insertions(+), 12 deletions(-)
diff --git a/backend/src/backend/program.cpp b/backend/src/backend/program.cpp
index 2c233ea..5eee4cb 100644
--- a/backend/src/backend/program.cpp
+++ b/backend/src/backend/program.cpp
@@ -630,7 +630,7 @@ namespace gbe {
args.push_back("spir");
#endif /* LLVM_VERSION_MINOR <= 2 */
args.push_back("stringInput.cl");
- args.push_back("-ffp-contract=off");
+ args.push_back("-ffp-contract=on");
if(OCL_DEBUGINFO) args.push_back("-g");
// The compiler invocation needs a DiagnosticsEngine so it can report problems
diff --git a/backend/src/llvm/llvm_gen_backend.cpp b/backend/src/llvm/llvm_gen_backend.cpp
index bbbd537..f43f870 100644
--- a/backend/src/llvm/llvm_gen_backend.cpp
+++ b/backend/src/llvm/llvm_gen_backend.cpp
@@ -3926,17 +3926,6 @@ namespace gbe
}
break;
#if LLVM_VERSION_MINOR >= 2
- case Intrinsic::fmuladd:
- {
- const ir::Register tmp = ctx.reg(ir::FAMILY_DWORD);
- const ir::Register dst = this->getRegister(&I);
- const ir::Register src0 = this->getRegister(I.getOperand(0));
- const ir::Register src1 = this->getRegister(I.getOperand(1));
- const ir::Register src2 = this->getRegister(I.getOperand(2));
- ctx.MUL(ir::TYPE_FLOAT, tmp, src0, src1);
- ctx.ADD(ir::TYPE_FLOAT, dst, tmp, src2);
- }
- break;
case Intrinsic::lifetime_start:
case Intrinsic::lifetime_end:
break;
@@ -4023,6 +4012,7 @@ namespace gbe
}
break;
case Intrinsic::fma:
+ case Intrinsic::fmuladd:
{
ir::Type srcType = getType(ctx, I.getType());
const ir::Register dst = this->getRegister(&I);
diff --git a/backend/src/llvm/llvm_scalarize.cpp b/backend/src/llvm/llvm_scalarize.cpp
index 9efb897..414bbac 100644
--- a/backend/src/llvm/llvm_scalarize.cpp
+++ b/backend/src/llvm/llvm_scalarize.cpp
@@ -269,6 +269,7 @@ namespace gbe {
case Intrinsic::sqrt:
case Intrinsic::ceil:
case Intrinsic::trunc:
+ case Intrinsic::fmuladd:
return true;
}
}
--
1.9.1
More information about the Beignet
mailing list