public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Binutils <binutils@sourceware.org>
Cc: "H.J. Lu" <hjl.tools@gmail.com>, Lili Cui <lili.cui@intel.com>
Subject: [PATCH 2/5] x86/SSE2AVX: move checking
Date: Fri, 22 Mar 2024 10:27:37 +0100	[thread overview]
Message-ID: <60c8dd45-52ec-4791-9250-5de996c6a948@suse.com> (raw)
In-Reply-To: <a5785897-7ef6-4c2f-8277-5069f702b7a8@suse.com>

It has always been looking a little odd to me that this was done deep
in cpu_flags_match(). Move it to match_template() itself - there's no
need to do anything complex when encountering such a template while it
cannot possibly be used.

--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -1980,17 +1980,7 @@ cpu_flags_match (const insn_template *t)
 
       cpu = cpu_flags_and (any, active);
       if (cpu_flags_all_zero (&any) || !cpu_flags_all_zero (&cpu))
-	{
-	  if (all.bitfield.cpuavx)
-	    {
-	      /* We need to check SSE2AVX with AVX.  */
-	      if (!t->opcode_modifier.sse2avx
-		  || (sse2avx && !i.prefix[DATA_PREFIX]))
-		match |= CPU_FLAGS_ARCH_MATCH;
-	    }
-	  else
-	    match |= CPU_FLAGS_ARCH_MATCH;
-	}
+	match |= CPU_FLAGS_ARCH_MATCH;
     }
   return match;
 }
@@ -8542,6 +8532,15 @@ match_template (char mnem_suffix)
       if (i.operands != t->operands)
 	continue;
 
+      /* Skip SSE2AVX templates when inapplicable.  */
+      if (t->opcode_modifier.sse2avx
+	  && (!sse2avx || i.prefix[DATA_PREFIX]))
+	{
+	  /* Another non-SSE2AVX template has to follow.  */
+	  gas_assert (t + 1 < current_templates.end);
+	  continue;
+	}
+
       /* Check processor support.  */
       specific_error = progress (unsupported);
       if (cpu_flags_match (t) != CPU_FLAGS_PERFECT_MATCH)


  parent reply	other threads:[~2024-03-22  9:27 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-22  9:25 [PATCH 0/5] x86/APX: respect -msse2avx Jan Beulich
2024-03-22  9:27 ` [PATCH 1/5] x86/SSE2AVX: respect prefixes Jan Beulich
2024-03-27  8:47   ` Cui, Lili
2024-03-27 11:31     ` Jan Beulich
2024-03-22  9:27 ` Jan Beulich [this message]
2024-03-27  9:38   ` [PATCH 2/5] x86/SSE2AVX: move checking Cui, Lili
2024-03-22  9:27 ` [PATCH 3/5] x86: zap value-less Disp8MemShift from non-EVEX templates Jan Beulich
2024-03-22  9:28 ` [PATCH 4/5] x86/APX: extend SSE2AVX coverage Jan Beulich
2024-03-29  9:10   ` Cui, Lili
2024-04-02  8:48     ` Jan Beulich
2024-04-03  7:59       ` Cui, Lili
2024-04-03  8:19         ` Jan Beulich
2024-04-03  9:17           ` Jiang, Haochen
2024-04-03  9:29             ` Cui, Lili
2024-04-03 10:22             ` Jan Beulich
2024-04-03  9:22           ` Cui, Lili
2024-04-05  7:09     ` Jan Beulich
2024-04-07  1:48       ` Cui, Lili
2024-04-08  6:25         ` Jan Beulich
2024-04-08  7:38           ` Cui, Lili
2024-03-22  9:29 ` [PATCH 5/5] x86: tidy <sse*> templates Jan Beulich

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=60c8dd45-52ec-4791-9250-5de996c6a948@suse.com \
    --to=jbeulich@suse.com \
    --cc=binutils@sourceware.org \
    --cc=hjl.tools@gmail.com \
    --cc=lili.cui@intel.com \
    /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).