[Beignet] [PATCH] Generate NAN for UNDEF value in printf parser.
junyan.he at inbox.com
junyan.he at inbox.com
Tue Mar 17 03:08:40 PDT 2015
From: Junyan He <junyan.he at linux.intel.com>
llvm 3.6 will give a UNDEF value for NAN. The will cause
the store instruction for UNDEF to be ignored. We need
to modify it to NAN here.
Signed-off-by: Junyan He <junyan.he at linux.intel.com>
---
backend/src/llvm/llvm_printf_parser.cpp | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/backend/src/llvm/llvm_printf_parser.cpp b/backend/src/llvm/llvm_printf_parser.cpp
index 7800c01..2f85443 100644
--- a/backend/src/llvm/llvm_printf_parser.cpp
+++ b/backend/src/llvm/llvm_printf_parser.cpp
@@ -831,6 +831,12 @@ error:
case Type::DoubleTyID:
case Type::FloatTyID: {
+ /* llvm 3.6 will give a undef value for NAN. */
+ if (dyn_cast<llvm::UndefValue>(arg)) {
+ APFloat nan = APFloat::getNaN(APFloat::IEEEsingle, false);
+ arg = ConstantFP::get(module->getContext(), nan);
+ }
+
/* Because the printf is a variable parameter function, it does not have the
function prototype, so the compiler will always promote the arg to the
longest precise type for float. So here, we can always find it is double. */
--
1.7.9.5
More information about the Beignet
mailing list