summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2018-07-24 09:47:47 -0700
committerH.J. Lu <hjl.tools@gmail.com>2018-07-24 09:51:08 -0700
commit56522fc5af76ec88f650d8d305c0aa3d669c2849 (patch)
tree3687b61be22ece0a823cff98ff4fa83741a82ea5
parent1d97232ae3655ad4f2661af34f4fa6038d492a25 (diff)
downloadbinutils-gdb-56522fc5af76ec88f650d8d305c0aa3d669c2849.tar.gz
x86: Use unsigned int to iterate through vector operands
Use unsigned int to iterate through multi-length vector operands to avoid sign-extension. * config/tc-i386.c (build_vex_prefix): Use unsigned int to iterate through multi-length vector operands. (build_evex_prefix): Likewise.
-rw-r--r--gas/ChangeLog6
-rw-r--r--gas/config/tc-i386.c10
2 files changed, 11 insertions, 5 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 7fb92597f09..c0b6801f893 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,9 @@
+2018-07-24 H.J. Lu <hongjiu.lu@intel.com>
+
+ * config/tc-i386.c (build_vex_prefix): Use unsigned int to
+ iterate through multi-length vector operands.
+ (build_evex_prefix): Likewise.
+
2018-07-24 Jan Beulich <jbeulich@suse.com>
* config/tc-i386.c (check_VecOperands): Handle EVEXLIG when
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index 81643a73ac4..bcd2904044c 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -3362,12 +3362,12 @@ build_vex_prefix (const insn_template *t)
vector_length = 1;
else
{
- int op;
+ unsigned int op;
/* Determine vector length from the last multi-length vector
operand. */
vector_length = 0;
- for (op = t->operands - 1; op >= 0; op--)
+ for (op = t->operands; op--;)
if (t->operand_types[op].bitfield.xmmword
&& t->operand_types[op].bitfield.ymmword
&& i.types[op].bitfield.ymmword)
@@ -3612,12 +3612,12 @@ build_evex_prefix (void)
if (!i.tm.opcode_modifier.evex
|| i.tm.opcode_modifier.evex == EVEXDYN)
{
- int op;
+ unsigned int op;
/* Determine vector length from the last multi-length vector
operand. */
vec_length = 0;
- for (op = i.operands - 1; op >= 0; op--)
+ for (op = i.operands; op--;)
if (i.tm.operand_types[op].bitfield.xmmword
+ i.tm.operand_types[op].bitfield.ymmword
+ i.tm.operand_types[op].bitfield.zmmword > 1)
@@ -3658,7 +3658,7 @@ build_evex_prefix (void)
}
}
- if (op < 0)
+ if (op >= MAX_OPERANDS)
abort ();
}