Commit 4f178718 authored by Milad Fa's avatar Milad Fa Committed by V8 LUCI CQ

PPC [simd]: Add tests for some word sized vector instructions

Change-Id: If641c8a4a466f6f9ea1dc9d8c15184fab17f52c7
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3098008
Commit-Queue: Milad Fa <mfarazma@redhat.com>
Reviewed-by: 's avatarZhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#76329}
parent ada169ed
......@@ -1038,6 +1038,51 @@ TEST(12) {
}
#endif
TEST(WordSizedVectorInstructions) {
CcTest::InitializeVM();
Isolate* isolate = CcTest::i_isolate();
HandleScope scope(isolate);
Assembler assm(AssemblerOptions{});
// Testing word sized vector operations.
__ li(r0, Operand(5)); // v0 = {5, 5, 5, 5}
__ mtvsrd(v0, r0);
__ vspltw(v0, v0, Operand(1));
// Integer
__ vadduwm(v1, v0, v0); // v1 = {10, 10, 10, 10}
__ vmuluwm(v2, v0, v1); // v2 = {50, 50, 50, 50}
__ vsubuhm(v3, v2, v0); // v3 = {45, 45, 45, 45}
__ vslw(v4, v2, v0); // v4 = {1600, 1600, 1600, 1600}
__ vsrw(v5, v2, v0); // v5 = {1, 1, 1, 1}
__ vmaxsw(v4, v5, v4); // v4 = unchanged
__ vcmpgtuw(v5, v2, v3); // v5 = all 1s
__ vand(v4, v4, v5); // v4 = unchanged
// FP
__ xvcvsxwsp(v1, v1); // v1 = Converted to SP
__ xvcvsxwsp(v4, v4); // v4 = Converted to SP
__ xvdivsp(v4, v4, v1); // v4 = {160, 160, 160, 160}
// Integer
__ xvcvspuxws(v4, v4); // v4 = Converted to Int
__ vor(v0, v4, v3); // v0 = {173, 173, 173, 173}
__ vupkhsw(v0, v0); // v0 = {173, 173}
__ mfvsrd(r3, v0);
__ blr();
CodeDesc desc;
assm.GetCode(isolate, &desc);
Handle<Code> code =
Factory::CodeBuilder(isolate, desc, CodeKind::FOR_TESTING).Build();
#ifdef DEBUG
code->Print();
#endif
auto f = GeneratedCode<F_iiiii>::FromCode(*code);
intptr_t res = reinterpret_cast<intptr_t>(f.Call(0, 0, 0, 0, 0));
::printf("f() = %" V8PRIdPTR "\n", res);
CHECK_EQ(173, static_cast<int>(res));
}
#undef __
} // namespace internal
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment