From 50ccad70b2cfd6b7e98ebf2730306d1864df7809 Mon Sep 17 00:00:00 2001 From: Wunkolo Date: Thu, 19 Mar 2026 13:39:49 -0700 Subject: [PATCH] [Testing] Add 'VECTOR_DENORMFLUSH_F32' unit test Unit tests the `OPCODE_VECTOR_DENORMFLUSH` implementation in isolation. --- .../cpu/testing/vector_flush_denorm_test.cc | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/xenia/cpu/testing/vector_flush_denorm_test.cc diff --git a/src/xenia/cpu/testing/vector_flush_denorm_test.cc b/src/xenia/cpu/testing/vector_flush_denorm_test.cc new file mode 100644 index 000000000..138be31ce --- /dev/null +++ b/src/xenia/cpu/testing/vector_flush_denorm_test.cc @@ -0,0 +1,45 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2026 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#include "xenia/cpu/testing/util.h" + +#include + +using namespace xe; +using namespace xe::cpu; +using namespace xe::cpu::hir; +using namespace xe::cpu::testing; +using xe::cpu::ppc::PPCContext; + +TEST_CASE("VECTOR_DENORMFLUSH_F32", "[instr]") { + TestFunction test([](HIRBuilder& b) { + StoreVR(b, 3, b.VectorDenormFlush(LoadVR(b, 4))); + b.Return(); + }); + test.Run([](PPCContext* ctx) { ctx->v[4] = vec128i(0x7fffff); }, + [](PPCContext* ctx) { + auto result = ctx->v[3]; + REQUIRE(result == vec128f(0.0f)); + }); + test.Run([](PPCContext* ctx) { ctx->v[4] = vec128i(0x807fffff); }, + [](PPCContext* ctx) { + auto result = ctx->v[3]; + REQUIRE(result == vec128f(-0.0f)); + }); + test.Run([](PPCContext* ctx) { ctx->v[4] = vec128f(FLT_MIN); }, + [](PPCContext* ctx) { + auto result = ctx->v[3]; + REQUIRE(result == vec128f(FLT_MIN)); + }); + test.Run([](PPCContext* ctx) { ctx->v[4] = vec128f(-FLT_MIN); }, + [](PPCContext* ctx) { + auto result = ctx->v[3]; + REQUIRE(result == vec128f(-FLT_MIN)); + }); +}