Otherwise, the following packet

  {
      L7:6 = combine(L0, L1)
      memw(R7) = L7.new
  }

results in memw(R7) being zero-intialized, compared to L6.new which
would correctly write the lower bytes of the pair.

Fixes: ef81d1b047337e81 ("target/hexagon: decode HLX packets and add load and 
store")
Signed-off-by: Anton Johansson <[email protected]>
---
 target/hexagon/decode.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/target/hexagon/decode.c b/target/hexagon/decode.c
index d48630da87..8921ff765d 100644
--- a/target/hexagon/decode.c
+++ b/target/hexagon/decode.c
@@ -110,9 +110,25 @@ static int hlx_find_new_value_producer(Packet *packet, int 
consumer,
 {
     for (int i = 0; i < packet->num_insns; i++) {
         Insn *insn = &packet->insn[i];
+        uint8_t regno;
 
-        if (i != consumer && GET_ATTRIB(insn->opcode, A_HLX) &&
-            insn->dest_idx != -1 && insn->regno[insn->dest_idx] == lreg) {
+        /*
+         * Skip ourselves, instructions without return values, and
+         * any non-HLX instructions.
+         */
+        if (i == consumer || !GET_ATTRIB(insn->opcode, A_HLX) ||
+            insn->dest_idx == -1) {
+            continue;
+        }
+
+        regno = insn->regno[insn->dest_idx];
+
+        /*
+         * Compare against the base register number, and against the top
+         * register for instructions returning pairs.
+         */
+        if (regno == lreg ||
+            (GET_ATTRIB(insn->opcode, A_HLX_PAIRED_ALU) && regno + 1 == lreg)) 
{
             return i;
         }
     }
-- 
2.52.0


Reply via email to