Subzero: implement Short4::Short4(RValue<Float4)
Implement non-optimized version. Should generalize and optimize code in
UShort4::UShort4(RValue<Float4> cast, bool saturate) so we can use it
here.
Bug: b/145754674
Change-Id: I16a24dab2979bb97d2d5f36a406aeb62aeb976e8
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/41928
Tested-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Reactor/SubzeroReactor.cpp b/src/Reactor/SubzeroReactor.cpp
index 911ec67..7196c79 100644
--- a/src/Reactor/SubzeroReactor.cpp
+++ b/src/Reactor/SubzeroReactor.cpp
@@ -2029,7 +2029,7 @@
const int64_t *i = constants;
const double *f = reinterpret_cast<const double *>(constants);
- // TODO(148082873): Fix global variable constants when generating multiple functions
+ // TODO(b/148082873): Fix global variable constants when generating multiple functions
Ice::Constant *ptr = nullptr;
switch((int)reinterpret_cast<intptr_t>(type))
@@ -2474,7 +2474,10 @@
Short4::Short4(RValue<Float4> cast)
{
- UNIMPLEMENTED_NO_BUG("Short4::Short4(RValue<Float4> cast)");
+ // TODO(b/150791192): Generalize and optimize
+ auto smin = std::numeric_limits<short>::min();
+ auto smax = std::numeric_limits<short>::max();
+ *this = Short4(Int4(Max(Min(cast, Float4(smax)), Float4(smin))));
}
RValue<Short4> operator<<(RValue<Short4> lhs, unsigned char rhs)