5 #include "radeon_compiler_util.h"
6 #include "radeon_program.h"
8 #include "r300_compiler_tests.h"
9 #include "rc_test_helpers.h"
10 #include "unit_test.h"
12 static void test_rc_inst_can_use_presub(
13 struct test_result
* result
,
16 const char * replace_str
)
18 struct rc_instruction add_inst
, replace_inst
;
22 init_rc_normal_instruction(&add_inst
, add_str
);
23 init_rc_normal_instruction(&replace_inst
, replace_str
);
25 ret
= rc_inst_can_use_presub(&replace_inst
, RC_PRESUB_ADD
, 0,
26 &replace_inst
.U
.I
.SrcReg
[0],
27 &add_inst
.U
.I
.SrcReg
[0], &add_inst
.U
.I
.SrcReg
[1]);
29 test_check(result
, ret
== expected
);
32 static void test_runner_rc_inst_can_use_presub(struct test_result
* result
)
35 /* This tests the case where the source being replace has the same
36 * register file and register index as another source register in the
37 * CMP instruction. A previous version of this function was ignoring
38 * all registers that shared the same file and index as the replacement
39 * register when counting the number of source selects.
41 * https://bugs.freedesktop.org/show_bug.cgi?id=36527
43 test_rc_inst_can_use_presub(result
, 0,
44 "ADD temp[0].z, temp[6].__x_, const[1].__x_;",
45 "CMP temp[0].y, temp[0]._z__, const[0]._z__, temp[0]._y__;");
48 /* Testing a random case that should fail
50 * https://bugs.freedesktop.org/show_bug.cgi?id=36527
52 test_rc_inst_can_use_presub(result
, 0,
53 "ADD temp[3], temp[1], temp[2];",
54 "MAD temp[1], temp[0], const[0].xxxx, -temp[3];");
56 /* This tests the case where the arguments of the ADD
57 * instruction share the same register file and index. Normally, we
58 * would need only one source select for these two arguments, but since
59 * they will be part of a presubtract operation we need to use the two
60 * source selects that the presubtract instruction expects
63 * https://bugs.freedesktop.org/show_bug.cgi?id=36527
65 test_rc_inst_can_use_presub(result
, 0,
66 "ADD temp[3].x, temp[0].x___, temp[0].x___;",
67 "MAD temp[0].xyz, temp[2].xyz_, -temp[3].xxx_, input[5].xyz_;");
70 void radeon_compiler_util_run_tests()
72 struct test tests
[] = {
73 {"rc_inst_can_use_presub()", test_runner_rc_inst_can_use_presub
},