[2/6] x86: simplify AVX checks in cpu_flags_match()

Message ID 5A9FF0EA02000078001AF5DD@prv-mh.provo.novell.com
State New
Headers show
Series
  • x86: fix/improve cpu_flags_match()
Related show

Commit Message

Jan Beulich March 7, 2018, 1:02 p.m.
No caller cares about the specifics of CPU_FLAGS_{AES,AVX,PCLMUL}_MATCH,
so drop those and fold the nested if()-s.

gas/
2018-03-07  Jan Beulich  <jbeulich@suse.com>

	* config/tc-i386.c (CPU_FLAGS_AES_MATCH, CPU_FLAGS_AVX_MATCH,
	CPU_FLAGS_PCLMUL_MATCH): Delete.
	(CPU_FLAGS_32BIT_MATCH): Drop uses of deleted CPU_FLAGS_*_MATCH.
	(cpu_flags_match): Combine AVX checks into
	single if().

Comments

H.J. Lu March 7, 2018, 1:39 p.m. | #1
On Wed, Mar 7, 2018 at 5:02 AM, Jan Beulich <JBeulich@suse.com> wrote:
> No caller cares about the specifics of CPU_FLAGS_{AES,AVX,PCLMUL}_MATCH,

> so drop those and fold the nested if()-s.

>

> gas/

> 2018-03-07  Jan Beulich  <jbeulich@suse.com>

>

>         * config/tc-i386.c (CPU_FLAGS_AES_MATCH, CPU_FLAGS_AVX_MATCH,

>         CPU_FLAGS_PCLMUL_MATCH): Delete.

>         (CPU_FLAGS_32BIT_MATCH): Drop uses of deleted CPU_FLAGS_*_MATCH.

>         (cpu_flags_match): Combine AVX checks into

>         single if().

>


OK.

Thanks.

-- 
H.J.

Patch

--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -1685,13 +1685,8 @@  cpu_flags_and_not (i386_cpu_flags x, i38
 
 #define CPU_FLAGS_ARCH_MATCH		0x1
 #define CPU_FLAGS_64BIT_MATCH		0x2
-#define CPU_FLAGS_AES_MATCH		0x4
-#define CPU_FLAGS_PCLMUL_MATCH		0x8
-#define CPU_FLAGS_AVX_MATCH	       0x10
-
-#define CPU_FLAGS_32BIT_MATCH \
-  (CPU_FLAGS_ARCH_MATCH | CPU_FLAGS_AES_MATCH \
-   | CPU_FLAGS_PCLMUL_MATCH | CPU_FLAGS_AVX_MATCH)
+
+#define CPU_FLAGS_32BIT_MATCH CPU_FLAGS_ARCH_MATCH
 #define CPU_FLAGS_PERFECT_MATCH \
   (CPU_FLAGS_32BIT_MATCH | CPU_FLAGS_64BIT_MATCH)
 
@@ -1722,22 +1717,11 @@  cpu_flags_match (const insn_template *t)
 	  if (x.bitfield.cpuavx)
 	    {
 	      /* We only need to check AES/PCLMUL/SSE2AVX with AVX.  */
-	      if (cpu.bitfield.cpuavx)
-		{
-		  /* Check SSE2AVX.  */
-		  if (!t->opcode_modifier.sse2avx|| sse2avx)
-		    {
-		      match |= (CPU_FLAGS_ARCH_MATCH
-				| CPU_FLAGS_AVX_MATCH);
-		      /* Check AES.  */
-		      if (!x.bitfield.cpuaes || cpu.bitfield.cpuaes)
-			match |= CPU_FLAGS_AES_MATCH;
-		      /* Check PCLMUL.  */
-		      if (!x.bitfield.cpupclmul
-			  || cpu.bitfield.cpupclmul)
-			match |= CPU_FLAGS_PCLMUL_MATCH;
-		    }
-		}
+	      if (cpu.bitfield.cpuavx
+		  && (!t->opcode_modifier.sse2avx || sse2avx)
+		  && (!x.bitfield.cpuaes || cpu.bitfield.cpuaes)
+		  && (!x.bitfield.cpupclmul || cpu.bitfield.cpupclmul))
+		match |= CPU_FLAGS_ARCH_MATCH;
 	    }
 	  else if (x.bitfield.cpuavx512vl)
 	    {