OSDN Git Service

Manually convert unsigned integer to floating-point.
authorNicolas Capens <capn@google.com>
Thu, 15 Dec 2016 19:45:13 +0000 (14:45 -0500)
committerNicolas Capens <capn@google.com>
Mon, 16 Jan 2017 18:54:27 +0000 (18:54 +0000)
commit96445fe36c80c3cb5443a29be673bedb7ad2fb2f
tree569ada158787c2f62cd609f7de5260ad6688e5cf
parent1675f9f5267812ab84bd70c16c12d35ef0e2dfd8
Manually convert unsigned integer to floating-point.

Subzero uses a helper function to convert uint to float. It's faster to
just emit a sequence of operations to perform the cast manually.
This implementation converts the lower 31 bits as a signed integer, and
adds 0x80000000 as a floating-point value when the upper bit is set.
This approach does not produce the correct rounding in rare cases, but
should still be adequate. For consistency, we're also using this method
with the LLVM back-end.

Change-Id: Ic5d7b73cd2a9e154056365cdbe9af0962bdbe1cb
Reviewed-on: https://swiftshader-review.googlesource.com/8312
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
src/Reactor/LLVMReactor.cpp
src/Reactor/Nucleus.hpp
src/Reactor/SubzeroReactor.cpp