mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-16 15:50:19 +01:00
agx: Add unit test for if_cmp fusing
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25052>
This commit is contained in:
parent
08e0c5a9cf
commit
bdad7992bc
1 changed files with 26 additions and 6 deletions
|
|
@ -14,24 +14,29 @@ agx_optimize_and_dce(agx_context *ctx)
|
|||
agx_dce(ctx, true);
|
||||
}
|
||||
|
||||
#define CASE(instr, expected, size) \
|
||||
#define CASE(instr, expected, size, returns) \
|
||||
INSTRUCTION_CASE( \
|
||||
{ \
|
||||
UNUSED agx_index out = agx_temp(b->shader, AGX_SIZE_##size); \
|
||||
instr; \
|
||||
agx_unit_test(b, out); \
|
||||
if (returns) \
|
||||
agx_unit_test(b, out); \
|
||||
}, \
|
||||
{ \
|
||||
UNUSED agx_index out = agx_temp(b->shader, AGX_SIZE_##size); \
|
||||
expected; \
|
||||
agx_unit_test(b, out); \
|
||||
if (returns) \
|
||||
agx_unit_test(b, out); \
|
||||
}, \
|
||||
agx_optimize_and_dce)
|
||||
|
||||
#define NEGCASE(instr, size) CASE(instr, instr, size)
|
||||
#define NEGCASE(instr, size) CASE(instr, instr, size, true)
|
||||
|
||||
#define CASE16(instr, expected) CASE(instr, expected, 16)
|
||||
#define CASE32(instr, expected) CASE(instr, expected, 32)
|
||||
#define CASE16(instr, expected) CASE(instr, expected, 16, true)
|
||||
#define CASE32(instr, expected) CASE(instr, expected, 32, true)
|
||||
|
||||
#define CASE_NO_RETURN(instr, expected) \
|
||||
CASE(instr, expected, 32 /* irrelevant */, false)
|
||||
|
||||
#define NEGCASE16(instr) NEGCASE(instr, 16)
|
||||
#define NEGCASE32(instr) NEGCASE(instr, 32)
|
||||
|
|
@ -194,3 +199,18 @@ TEST_F(Optimizer, NoConversionsOn16BitALU)
|
|||
|
||||
NEGCASE32(agx_fmov_to(b, out, agx_fadd(b, hx, hy)));
|
||||
}
|
||||
|
||||
TEST_F(Optimizer, IfCondition)
|
||||
{
|
||||
CASE_NO_RETURN(agx_if_icmp(b, agx_icmp(b, wx, wy, AGX_ICOND_UEQ, true),
|
||||
agx_zero(), 1, AGX_ICOND_UEQ, true),
|
||||
agx_if_icmp(b, wx, wy, 1, AGX_ICOND_UEQ, true));
|
||||
|
||||
CASE_NO_RETURN(agx_if_icmp(b, agx_fcmp(b, wx, wy, AGX_FCOND_EQ, true),
|
||||
agx_zero(), 1, AGX_ICOND_UEQ, true),
|
||||
agx_if_fcmp(b, wx, wy, 1, AGX_FCOND_EQ, true));
|
||||
|
||||
CASE_NO_RETURN(agx_if_icmp(b, agx_fcmp(b, hx, hy, AGX_FCOND_LT, false),
|
||||
agx_zero(), 1, AGX_ICOND_UEQ, true),
|
||||
agx_if_fcmp(b, hx, hy, 1, AGX_FCOND_LT, false));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue