Skip to contentSkip to conversation

Hexagon (gen_tcg_funcs.py): avoid duplicated tcg code on A_CVI_NEW

PATCH In review Matheus Tavares Bernardino 4 participants 4 messages Sep 30, 2022 – Oct 3, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Hexagon (gen_tcg_funcs.py): avoid duplicated tcg code on A_CVI_NEW

Hexagon instructions with the A_CVI_NEW attribute produce a vector value that can be used in the same packet. The python function responsible for generating code for such instructions has a typo ("if" instead of "elif"), which makes genptr_dst_write_ext() be executed twice, thus also generating the same tcg code twice. Fortunately, this doesn't cause any problems for correctness, but it is less efficient than it could be. Fix it by using an "elif" and avoiding the unnecessary extra code gen.

---
 target/hexagon/gen_tcg_funcs.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/hexagon/gen_tcg_funcs.py +1 -1
index d72c689ad7..6dea02b0b9 100755
@@ -548,7 +548,7 @@ def genptr_dst_write_opn(f,regtype, regid, tag):
         if (hex_common.is_hvx_reg(regtype)):
             if (hex_common.is_new_result(tag)):
                 genptr_dst_write_ext(f, tag, regtype, regid, "EXT_NEW")
-            if (hex_common.is_tmp_result(tag)):
+            elif (hex_common.is_tmp_result(tag)):
                 genptr_dst_write_ext(f, tag, regtype, regid, "EXT_TMP")
             else:
                 genptr_dst_write_ext(f, tag, regtype, regid, "EXT_DFL")
Signature · 1 line
2.37.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 18 lines · Matheus Tavares Bernardino

Hexagon instructions with the A_CVI_NEW attribute produce a vector value that can be used in the same packet. The python function responsible for generating code for such instructions has a typo ("if" instead of "elif"), which makes genptr_dst_write_ext() be executed twice, thus also generating the same tcg code twice. Fortunately, this doesn't cause any problems for correctness, but it is less efficient than it could be. Fix it by using an "elif" and avoiding the unnecessary extra code gen.

---
  target/hexagon/gen_tcg_funcs.py | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
target/hexagon/gen_tcg_funcs.py +0 -0
index d72c689ad7..6dea02b0b9 100755

target/hexagon/gen_tcg_funcs.py def genptr_dst_write_opn(f,regtype, regid, tag): · line 554

Quoted 8 lines
target/hexagon/gen_tcg_funcs.py +1 -1
@@ -548,7 +548,7 @@ def genptr_dst_write_opn(f,regtype, regid, tag):
          if (hex_common.is_hvx_reg(regtype)):
              if (hex_common.is_new_result(tag)):
                  genptr_dst_write_ext(f, tag, regtype, regid, "EXT_NEW")
-            if (hex_common.is_tmp_result(tag)):
+            elif (hex_common.is_tmp_result(tag)):
                  genptr_dst_write_ext(f, tag, regtype, regid, "EXT_TMP")
              else:
                  genptr_dst_write_ext(f, tag, regtype, regid, "EXT_DFL")

r~

Reviewed-by on v1 1/1
#2 lore raw
In reply to Matheus Tavares Bernardino
Quoted 28 lines

-----Original Message-----
From: Matheus Tavares Bernardino <[email protected]>
Sent: Friday, September 30, 2022 3:08 PM
To: [email protected]
Cc: Taylor Simpson <[email protected]>
Subject: [PATCH] Hexagon (gen_tcg_funcs.py): avoid duplicated tcg code on A_CVI_NEW

Hexagon instructions with the A_CVI_NEW attribute produce a vector value that can be used in the same packet. The python function responsible for generating code for such instructions has a typo ("if" instead of "elif"), which makes genptr_dst_write_ext() be executed twice, thus also generating the same tcg code twice. Fortunately, this doesn't cause any problems for correctness, but it is less efficient than it could be. Fix it by using an "elif" and avoiding the unnecessary extra code gen.

---
 target/hexagon/gen_tcg_funcs.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/target/hexagon/gen_tcg_funcs.py index d72c689ad7..6dea02b0b9 100755

target/hexagon/gen_tcg_funcs.py def genptr_dst_write_opn(f,regtype, regid, tag): · line 554

Quoted 8 lines
target/hexagon/gen_tcg_funcs.py +1 -1
@@ -548,7 +548,7 @@ def genptr_dst_write_opn(f,regtype, regid, tag):
         if (hex_common.is_hvx_reg(regtype)):
             if (hex_common.is_new_result(tag)):
                 genptr_dst_write_ext(f, tag, regtype, regid, "EXT_NEW")
-            if (hex_common.is_tmp_result(tag)):
+            elif (hex_common.is_tmp_result(tag)):
                 genptr_dst_write_ext(f, tag, regtype, regid, "EXT_TMP")
             else:
                 genptr_dst_write_ext(f, tag, regtype, regid, "EXT_DFL")
Reviewed-by Philippe Mathieu-Daudé on v1 1/1
#3 lore raw
In reply to Matheus Tavares Bernardino
Quoted 8 lines · Matheus Tavares Bernardino

Hexagon instructions with the A_CVI_NEW attribute produce a vector value that can be used in the same packet. The python function responsible for generating code for such instructions has a typo ("if" instead of "elif"), which makes genptr_dst_write_ext() be executed twice, thus also generating the same tcg code twice. Fortunately, this doesn't cause any problems for correctness, but it is less efficient than it could be. Fix it by using an "elif" and avoiding the unnecessary extra code gen.

Quoted 4 lines
---
  target/hexagon/gen_tcg_funcs.py | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)