diff --git a/tests/test_image_bvh_census.py b/tests/test_image_bvh_census.py index 86f836fce1..d6aeaea298 100644 --- a/tests/test_image_bvh_census.py +++ b/tests/test_image_bvh_census.py @@ -302,6 +302,23 @@ def test_v_cmpx_e32_does_not_clobber_sgpr_source_and_e64_product_reader(self): self.assertIn((2, "raw_integer", "all"), [e[1:4] for e in site["reads"]]) self.assertEqual([p[1:] for p in site["product_reads"]], [("v_cmpx_gt_i32 with 0", "all")]) + def test_short_carry_form_keeps_an_sgpr_literal_source(self): + # The three-operand carry forms print dst, src0, src1 with VCC implicit, so a[1] is a source there and + # s8 keeps its literal. The explicit VCC form and the VOP3b form still name the carry destination in a[1]. + for form in ("v_add_co_ci_u32 v1, s8, v2", + "v_sub_co_ci_u32 v1, s8, v2", + "v_subrev_co_ci_u32 v1, s8, v2", + "v_add_co_ci_u32_e32 v1, vcc, s8, v2, vcc"): + with self.subTest(form=form): + (site,) = analyse("s_mov_b32 s8, 5", form, CALL32, "s_endpgm") + self.assertEqual(site["desc"][0], 5) + one = {"k": "vgpr", "r": 1, "n": 1} + two = {"k": "vgpr", "r": 2, "n": 1} + s8 = {"k": "sgpr", "r": 8, "n": 1} + self.assertEqual(census.mask_writes({"op": "v_add_co_ci_u32", "args": [one, s8, two]}), []) + self.assertEqual(census.mask_writes({"op": "v_add_co_ci_u32_e64", + "args": [one, s8, two, {"k": "vgpr", "r": 3, "n": 1}]}), [8]) + def test_modified_v_rcp_f32_does_not_tag_ratio_reciprocal(self): for rcp in ( "v_rcp_f32_e64 v20, |v5|", diff --git a/tools/image_bvh_census.py b/tools/image_bvh_census.py index caa75426cb..24b8ec2e15 100644 --- a/tools/image_bvh_census.py +++ b/tools/image_bvh_census.py @@ -328,8 +328,9 @@ def sgpr_step(sg, ins): written = [] if a and not op.startswith(SALU_NO_DST) and not (bop.startswith("v_cmpx") and len(a) <= 2): written += sregs(a[0]) # SALU destinations, v_cmp_*_e64 / v_readlane_b32 SGPR destinations - if len(a) > 1 and ("_co_" in bop or bop.startswith("v_div_scale")): - written += sregs(a[1]) # the carry / scale SGPR of a VOP3b op + if len(a) > 3 and ("_co_" in bop or bop.startswith("v_div_scale")): + written += sregs(a[1]) # the carry / scale SGPR of a VOP3b op: a[1] is that destination + # (the short e32 carry forms print dst, src0, src1 with VCC implicit, so a[1] is a source there) value = {} if bop in ("s_mov_b32", "s_movk_i32", "s_brev_b32") and len(a) == 2 and len(sregs(a[0])) == 1: v = imm32(a[1]) @@ -471,7 +472,7 @@ def mask_writes(ins): out = [] if a and not op.startswith(SALU_NO_DST) and not (bop.startswith("v_cmpx") and len(a) <= 2): out += sregs(a[0]) - if len(a) > 1 and ("_co_" in bop or bop.startswith("v_div_scale")): + if len(a) > 3 and ("_co_" in bop or bop.startswith("v_div_scale")): out += sregs(a[1]) return out