Fixed some unary operators
There were a few issues in unary operators:
- Many were not compiling because the promote function had not
been adjusted to take the new builtin functions into account
- abs and sign had not been implemented for int
- For the integer abs version, used pabsd. Removed the extra
argument, which seemed unnecessary (abs should have 1 input,
1 output, AFAIK).
Change-Id: If02c5040438e8c45c99fc7b3c55107448c85cf58
Reviewed-on: https://swiftshader-review.googlesource.com/4970
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/src/Reactor/Nucleus.cpp b/src/Reactor/Nucleus.cpp
index ce48b52..9b1d245 100644
--- a/src/Reactor/Nucleus.cpp
+++ b/src/Reactor/Nucleus.cpp
@@ -3579,6 +3579,19 @@
return x86::pmaddwd(x, y); // FIXME: Fallback required
}
+ RValue<Int4> Abs(RValue<Int4> x)
+ {
+ if(CPUID::supportsSSSE3())
+ {
+ return x86::pabsd(x);
+ }
+ else
+ {
+ Int4 mask = (x >> 31);
+ return (mask ^ x) - mask;
+ }
+ }
+
RValue<Short8> MulHigh(RValue<Short8> x, RValue<Short8> y)
{
return x86::pmulhw(x, y); // FIXME: Fallback required
@@ -7157,12 +7170,12 @@
return cmpss(x, y, 7);
}
- RValue<Int4> pabsd(RValue<Int4> x, RValue<Int4> y)
+ RValue<Int4> pabsd(RValue<Int4> x)
{
Module *module = Nucleus::getModule();
llvm::Function *pabsd = Intrinsic::getDeclaration(module, Intrinsic::x86_ssse3_pabs_d_128);
- return RValue<Int4>(Nucleus::createCall(pabsd, x.value, y.value));
+ return RValue<Int4>(Nucleus::createCall(pabsd, x.value));
}
RValue<Short4> paddsw(RValue<Short4> x, RValue<Short4> y)