Fix rounding to nearest integer.
Change-Id: I2fbd6524f1975f2c76ae0b5e544f323e7c7e4537
Reviewed-on: https://swiftshader-review.googlesource.com/8269
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/src/Reactor/SubzeroReactor.cpp b/src/Reactor/SubzeroReactor.cpp
index 07ea893..ccebeea 100644
--- a/src/Reactor/SubzeroReactor.cpp
+++ b/src/Reactor/SubzeroReactor.cpp
@@ -4122,8 +4122,10 @@
RValue<Int> RoundInt(RValue<Float> cast)
{
+ RValue<Float> rounded = Round(cast);
+
Ice::Variable *result = ::function->makeVariable(Ice::IceType_i32);
- auto round = Ice::InstCast::create(::function, Ice::InstCast::Fptosi, result, cast.value);
+ auto round = Ice::InstCast::create(::function, Ice::InstCast::Fptosi, result, rounded.value);
::basicBlock->appendInst(round);
return RValue<Int>(V(result));
@@ -5336,8 +5338,10 @@
RValue<Int4> RoundInt(RValue<Float4> cast)
{
+ RValue<Float4> rounded = Round(cast);
+
Ice::Variable *result = ::function->makeVariable(Ice::IceType_v4i32);
- auto round = Ice::InstCast::create(::function, Ice::InstCast::Fptosi, result, cast.value);
+ auto round = Ice::InstCast::create(::function, Ice::InstCast::Fptosi, result, rounded.value);
::basicBlock->appendInst(round);
return RValue<Int4>(V(result));