OSDN Git Service

Add test for MulHigh in Reactor
authorCasey Dahlin <sadmac@google.com>
Mon, 2 Oct 2017 22:02:02 +0000 (15:02 -0700)
committerCasey Dahlin <sadmac@google.com>
Mon, 2 Oct 2017 22:10:31 +0000 (22:10 +0000)
Test: New tests pass
Bug: b/37496856
Change-Id: Ifae1f802d61a7d51f6e8f5c135e3c8c67be30125
Reviewed-on: https://swiftshader-review.googlesource.com/12950
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Casey Dahlin <sadmac@google.com>
src/Reactor/Main.cpp

index a1bb0fb..0d22f4d 100644 (file)
@@ -882,6 +882,47 @@ TEST(SubzeroReactorTest, Pack)
        delete routine;
 }
 
+TEST(SubzeroReactorTest, MulHigh) {
+       Routine *routine = nullptr;
+
+       {
+               Function<Int(Pointer<Byte>)> function;
+               {
+                       Pointer<Byte> out = function.Arg<0>();
+
+                       *Pointer<Short4>(out + 8 * 0) =
+                               MulHigh(Short4(0x1aa, 0x2dd, 0x3ee, 0xF422),
+                                       Short4(0x1bb, 0x2cc, 0x3ff, 0xF411));
+                       *Pointer<UShort4>(out + 8 * 1) =
+                               MulHigh(UShort4(0x1aa, 0x2dd, 0x3ee, 0xF422),
+                                       UShort4(0x1bb, 0x2cc, 0x3ff, 0xF411));
+
+                       // (U)Short8 variants are mentioned but unimplemented
+                       Return(0);
+               }
+
+               routine = function(L"one");
+
+               if(routine)
+               {
+                       int out[2][2];
+
+                       memset(&out, 0, sizeof(out));
+
+                       int(*callable)(void*) = (int(*)(void*))routine->getEntry();
+                       callable(&out);
+
+                       EXPECT_EQ((unsigned)out[0][0], 0x00080002);
+                       EXPECT_EQ((unsigned)out[0][1], 0x008d000f);
+
+                       EXPECT_EQ((unsigned)out[1][0], 0x00080002);
+                       EXPECT_EQ((unsigned)out[1][1], 0xe8c0000f);
+               }
+       }
+
+       delete routine;
+}
+
 int main(int argc, char **argv)
 {
        ::testing::InitGoogleTest(&argc, argv);