x86/Intel: adjustment to restricted suffix derivation

Message ID 661d0e07-cc75-0fba-941b-88160dbcbb13@suse.com
State Accepted
Headers
Series x86/Intel: adjustment to restricted suffix derivation |

Checks

Context Check Description
snail/binutils-gdb-check success Github commit url

Commit Message

Jan Beulich Nov. 28, 2022, 2:24 p.m. UTC
  In "x86/Intel: restrict suffix derivation" I think I screwed up
slightly, bringing a piece of code out of sync with its comment, and
resulting in a suffix potentially being derived when one isn't needed.
---
Really we could go further and check whether _any_ register-only operand
in a template permits for multiple sizes, thus implying that operand
size can be derived from it. But that would involve looping over all
operands, when we'd like to keep the checking here quick.
  

Patch

--- a/gas/config/tc-i386-intel.c
+++ b/gas/config/tc-i386-intel.c
@@ -841,11 +841,16 @@  i386_intel_operand (char *operand_string
 		  abort ();
 		}
 
+	      /* We can skip templates with swappable operands here, as one
+		 operand will be a register, which operand size can be
+		 determined from.  */
+	      if (t->opcode_modifier.d)
+		continue;
+
 	      /* In a few cases suffixes are permitted, but we can nevertheless
 		 derive that these aren't going to be needed.  This is only of
-		 interest for insns using ModR/M, plus we can skip templates with
-		 swappable operands here (simplifying subsequent logic).  */
-	      if (!t->opcode_modifier.modrm || t->opcode_modifier.d)
+		 interest for insns using ModR/M.  */
+	      if (!t->opcode_modifier.modrm)
 		break;
 
 	      if (!t->operand_types[op].bitfield.baseindex)