public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@sourceware.org>
To: bfd-cvs@sourceware.org
Subject: [binutils-gdb] x86: re-work EVEX-z-without-masking check
Date: Tue,  4 Jul 2023 15:02:29 +0000 (GMT)	[thread overview]
Message-ID: <20230704150229.5A21E3858D35@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=07d618b91f50816f198abac7df116e83d47ca1be

commit 07d618b91f50816f198abac7df116e83d47ca1be
Author: Jan Beulich <jbeulich@suse.com>
Date:   Tue Jul 4 17:00:15 2023 +0200

    x86: re-work EVEX-z-without-masking check
    
    Rather than corrupting disassmbly altogether, flag EVEX.z set as bad
    when masking isn't in effect in the first place at the time the
    destination operand is actually processed.

Diff:
---
 gas/testsuite/gas/i386/avx512f-nondef.d |  3 +--
 opcodes/i386-dis.c                      | 18 ++++++++----------
 2 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/gas/testsuite/gas/i386/avx512f-nondef.d b/gas/testsuite/gas/i386/avx512f-nondef.d
index a062fe335bc..8defd6972e5 100644
--- a/gas/testsuite/gas/i386/avx512f-nondef.d
+++ b/gas/testsuite/gas/i386/avx512f-nondef.d
@@ -15,8 +15,7 @@ Disassembly of section .text:
 [ 	]*[a-f0-9]+:	62 f2 55 1f 3b f4    	vpminud \{rn-bad\},%zmm4,%zmm5,%zmm6\{%k7\}
 [ 	]*[a-f0-9]+:	62 f2 7e 48 31 72 7f 	vpmovdb %zmm6,0x7f0\(%edx\)
 [ 	]*[a-f0-9]+:	62 f2 7e 58 31 72 7f 	vpmovdb %zmm6,0x7f0\(%edx\)\{bad\}
-[ 	]*[a-f0-9]+:	62 f1 7c 88 58       	\(bad\)
-[ 	]*[a-f0-9]+:	c3                   	ret
+[ 	]*[a-f0-9]+:	62 f1 7c 88 58 c3    	(\{evex\} )?vaddps %xmm3,%xmm0,%xmm0\{bad\}
 [ 	]*[a-f0-9]+:	62 f2 7d 4f 92 01    	vgatherdps \(bad\),%zmm0\{%k7\}
 [ 	]*[a-f0-9]+:	67 62 f2 7d 4f 92 01 	addr16 vgatherdps \(bad\),%zmm0\{%k7\}
 [ 	]*[a-f0-9]+:	62 f2 7d cf 92 04 08 	vgatherdps \(%eax,%zmm1(,1)?\),%zmm0\{%k7\}\{z\}/\(bad\)
diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c
index 15a0e1b1080..690e336c6bc 100644
--- a/opcodes/i386-dis.c
+++ b/opcodes/i386-dis.c
@@ -9905,9 +9905,15 @@ print_insn (bfd_vma pc, disassemble_info *info, int intel_syntax)
 		      oappend (&ins, "{");
 		      oappend_register (&ins, reg_name);
 		      oappend (&ins, "}");
+
+		      if (ins.vex.zeroing)
+			oappend (&ins, "{z}");
+		    }
+		  else if (ins.vex.zeroing)
+		    {
+		      oappend (&ins, "{bad}");
+		      continue;
 		    }
-		  if (ins.vex.zeroing)
-		    oappend (&ins, "{z}");
 
 		  /* S/G insns require a mask and don't allow
 		     zeroing-masking.  */
@@ -9985,14 +9991,6 @@ print_insn (bfd_vma pc, disassemble_info *info, int intel_syntax)
       goto out;
     }
 
-  /* If EVEX.z is set, there must be an actual mask register in use.  */
-  if (ins.vex.zeroing && ins.vex.mask_register_specifier == 0)
-    {
-      i386_dis_printf (info, dis_style_text, "(bad)");
-      ret = ins.end_codep - priv.the_buffer;
-      goto out;
-    }
-
   switch (dp->prefix_requirement)
     {
     case PREFIX_DATA:

                 reply	other threads:[~2023-07-04 15:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230704150229.5A21E3858D35@sourceware.org \
    --to=jbeulich@sourceware.org \
    --cc=bfd-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).