Jakub Jelinek 79c245
--- valgrind/VEX/priv/guest_amd64_toIR.c.jj	2010-10-20 22:19:51.000000000 +0200
Jakub Jelinek 79c245
+++ valgrind/VEX/priv/guest_amd64_toIR.c	2010-11-05 17:34:50.179705231 +0100
Jakub Jelinek 79c245
@@ -15957,17 +15957,19 @@ DisResult disInstr_AMD64_WRK ( 
Jakub Jelinek 0332e1
    case 0xE1: /* LOOPE  disp8: decrement count, jump if count != 0 && ZF==1 */
Jakub Jelinek 0332e1
    case 0xE2: /* LOOP   disp8: decrement count, jump if count != 0 */
Jakub Jelinek 0332e1
     { /* The docs say this uses rCX as a count depending on the
Jakub Jelinek 0332e1
-         address size override, not the operand one.  Since we don't
Jakub Jelinek 0332e1
-         handle address size overrides, I guess that means RCX. */
Jakub Jelinek 0332e1
+         address size override, not the operand one.  */
Jakub Jelinek 0332e1
       IRExpr* zbit  = NULL;
Jakub Jelinek 0332e1
       IRExpr* count = NULL;
Jakub Jelinek 0332e1
       IRExpr* cond  = NULL;
Jakub Jelinek 0332e1
       HChar*  xtra  = NULL;
Jakub Jelinek 0332e1
 
Jakub Jelinek 0332e1
-      if (have66orF2orF3(pfx) || haveASO(pfx)) goto decode_failure;
Jakub Jelinek 0332e1
+      if (have66orF2orF3(pfx)) goto decode_failure;
Jakub Jelinek 0332e1
       d64 = guest_RIP_bbstart+delta+1 + getSDisp8(delta);
Jakub Jelinek 0332e1
       delta++;
Jakub Jelinek 0332e1
-      putIReg64(R_RCX, binop(Iop_Sub64, getIReg64(R_RCX), mkU64(1)));
Jakub Jelinek 0332e1
+      if (haveASO (pfx))
Jakub Jelinek 0332e1
+         putIReg32(R_RCX, binop(Iop_Sub32, getIReg32(R_RCX), mkU32(1)));
Jakub Jelinek 0332e1
+      else
Jakub Jelinek 0332e1
+         putIReg64(R_RCX, binop(Iop_Sub64, getIReg64(R_RCX), mkU64(1)));
Jakub Jelinek 0332e1
 
Jakub Jelinek 0332e1
       count = getIReg64(R_RCX);
Jakub Jelinek 0332e1
       cond = binop(Iop_CmpNE64, count, mkU64(0));
Jakub Jelinek 79c245
--- valgrind/none/tests/amd64/loopnel.c.jj	2010-11-05 17:34:50.180705082 +0100
Jakub Jelinek 79c245
+++ valgrind/none/tests/amd64/loopnel.c	2010-11-05 17:34:50.180705082 +0100
Jakub Jelinek 0332e1
@@ -0,0 +1,11 @@
Jakub Jelinek 0332e1
+#include <stdio.h>
Jakub Jelinek 0332e1
+
Jakub Jelinek 0332e1
+int
Jakub Jelinek 0332e1
+main (void)
Jakub Jelinek 0332e1
+{
Jakub Jelinek 0332e1
+  long rcx = 0x200000005UL;
Jakub Jelinek 0332e1
+  long rax = 5UL;
Jakub Jelinek 0332e1
+  asm volatile ("1: addq $1, %0; loopnel 1b" : "+a" (rax), "+c" (rcx) : : "cc");
Jakub Jelinek 0332e1
+  printf ("%ld %ld\n", rax, rcx);
Jakub Jelinek 0332e1
+  return 0;
Jakub Jelinek 0332e1
+}
Jakub Jelinek 79c245
--- valgrind/none/tests/amd64/loopnel.vgtest.jj	2010-11-05 17:34:50.180705082 +0100
Jakub Jelinek 79c245
+++ valgrind/none/tests/amd64/loopnel.vgtest	2010-11-05 17:34:50.180705082 +0100
Jakub Jelinek 0332e1
@@ -0,0 +1 @@
Jakub Jelinek 0332e1
+prog: loopnel
Jakub Jelinek 79c245
--- valgrind/none/tests/amd64/loopnel.stdout.exp.jj	2010-11-05 17:34:50.181705073 +0100
Jakub Jelinek 79c245
+++ valgrind/none/tests/amd64/loopnel.stdout.exp	2010-11-05 17:34:50.181705073 +0100
Jakub Jelinek 0332e1
@@ -0,0 +1 @@
Jakub Jelinek 0332e1
+10 0
Jakub Jelinek 79c245
--- valgrind/none/tests/amd64/loopnel.stderr.exp.jj	2010-11-05 17:34:50.181705073 +0100
Jakub Jelinek 79c245
+++ valgrind/none/tests/amd64/loopnel.stderr.exp	2010-11-05 17:34:50.181705073 +0100
Jakub Jelinek 0332e1
@@ -0,0 +1,2 @@
Jakub Jelinek 0332e1
+
Jakub Jelinek 0332e1
+
Jakub Jelinek 79c245
--- valgrind/none/tests/amd64/Makefile.am.jj	2010-10-20 22:19:31.000000000 +0200
Jakub Jelinek 79c245
+++ valgrind/none/tests/amd64/Makefile.am	2010-11-05 17:35:44.779455280 +0100
Jakub Jelinek 79c245
@@ -44,6 +44,7 @@ EXTRA_DIST = \
Jakub Jelinek 0332e1
 	insn_ssse3.stdout.exp insn_ssse3.stderr.exp insn_ssse3.vgtest \
Jakub Jelinek 0332e1
 	jrcxz.stderr.exp jrcxz.stdout.exp jrcxz.vgtest \
Jakub Jelinek 0332e1
 	looper.stderr.exp looper.stdout.exp looper.vgtest \
Jakub Jelinek 0332e1
+	loopnel.stderr.exp loopnel.stdout.exp loopnel.vgtest \
Jakub Jelinek 79c245
 	lzcnt64.stderr.exp lzcnt64.stdout.exp lzcnt64.vgtest \
Jakub Jelinek 0332e1
 	nibz_bennee_mmap.stderr.exp nibz_bennee_mmap.stdout.exp \
Jakub Jelinek 0332e1
 	nibz_bennee_mmap.vgtest \
Jakub Jelinek 79c245
@@ -88,6 +89,7 @@ if ! VGCONF_OS_IS_DARWIN
Jakub Jelinek 0332e1
 	fcmovnu \
Jakub Jelinek 0332e1
 	fxtract \
Jakub Jelinek 0332e1
 	looper \
Jakub Jelinek 0332e1
+	loopnel \
Jakub Jelinek 0332e1
 	jrcxz \
Jakub Jelinek 0332e1
 	shrld \
Jakub Jelinek 0332e1
 	slahf-amd64
Jakub Jelinek 79c245
--- valgrind/none/tests/amd64/Makefile.in.jj	2010-10-21 03:16:16.000000000 +0200
Jakub Jelinek 79c245
+++ valgrind/none/tests/amd64/Makefile.in	2010-11-05 17:36:25.698704330 +0100
Jakub Jelinek 79c245
@@ -66,6 +66,7 @@ check_PROGRAMS = amd64locked$(EXEEXT) bu
Jakub Jelinek 0332e1
 @VGCONF_OS_IS_DARWIN_FALSE@	fcmovnu \
Jakub Jelinek 0332e1
 @VGCONF_OS_IS_DARWIN_FALSE@	fxtract \
Jakub Jelinek 0332e1
 @VGCONF_OS_IS_DARWIN_FALSE@	looper \
Jakub Jelinek 0332e1
+@VGCONF_OS_IS_DARWIN_FALSE@	loopnel \
Jakub Jelinek 0332e1
 @VGCONF_OS_IS_DARWIN_FALSE@	jrcxz \
Jakub Jelinek 0332e1
 @VGCONF_OS_IS_DARWIN_FALSE@	shrld \
Jakub Jelinek 0332e1
 @VGCONF_OS_IS_DARWIN_FALSE@	slahf-amd64
Jakub Jelinek 79c245
@@ -91,8 +92,9 @@ am__EXEEXT_4 = insn_basic$(EXEEXT) insn_
Jakub Jelinek 0332e1
 @VGCONF_OS_IS_DARWIN_FALSE@	bug156404-amd64$(EXEEXT) \
Jakub Jelinek 0332e1
 @VGCONF_OS_IS_DARWIN_FALSE@	faultstatus$(EXEEXT) \
Jakub Jelinek 0332e1
 @VGCONF_OS_IS_DARWIN_FALSE@	fcmovnu$(EXEEXT) fxtract$(EXEEXT) \
Jakub Jelinek 0332e1
-@VGCONF_OS_IS_DARWIN_FALSE@	looper$(EXEEXT) jrcxz$(EXEEXT) \
Jakub Jelinek 0332e1
-@VGCONF_OS_IS_DARWIN_FALSE@	shrld$(EXEEXT) slahf-amd64$(EXEEXT)
Jakub Jelinek 0332e1
+@VGCONF_OS_IS_DARWIN_FALSE@	looper$(EXEEXT) loopnel$(EXEEXT) \
Jakub Jelinek 0332e1
+@VGCONF_OS_IS_DARWIN_FALSE@	jrcxz$(EXEEXT) shrld$(EXEEXT) \
Jakub Jelinek 0332e1
+@VGCONF_OS_IS_DARWIN_FALSE@	slahf-amd64$(EXEEXT)
Jakub Jelinek 0332e1
 amd64locked_SOURCES = amd64locked.c
Jakub Jelinek 0332e1
 amd64locked_OBJECTS = amd64locked-amd64locked.$(OBJEXT)
Jakub Jelinek 0332e1
 amd64locked_LDADD = $(LDADD)
Jakub Jelinek 79c245
@@ -158,6 +160,9 @@ jrcxz_LDADD = $(LDADD)
Jakub Jelinek 0332e1
 looper_SOURCES = looper.c
Jakub Jelinek 0332e1
 looper_OBJECTS = looper.$(OBJEXT)
Jakub Jelinek 0332e1
 looper_LDADD = $(LDADD)
Jakub Jelinek 79c245
+loopnel_SOURCES = loopnel.c
Jakub Jelinek 0332e1
+loopnel_OBJECTS = loopnel.$(OBJEXT)
Jakub Jelinek 0332e1
+loopnel_LDADD = $(LDADD)
Jakub Jelinek 79c245
 lzcnt64_SOURCES = lzcnt64.c
Jakub Jelinek 79c245
 lzcnt64_OBJECTS = lzcnt64.$(OBJEXT)
Jakub Jelinek 79c245
 lzcnt64_LDADD = $(LDADD)
Jakub Jelinek 79c245
@@ -202,7 +207,7 @@ SOURCES = amd64locked.c bug127521-64.c b
Jakub Jelinek 0332e1
 	faultstatus.c fcmovnu.c fxtract.c $(insn_basic_SOURCES) \
Jakub Jelinek 79c245
 	$(insn_fpu_SOURCES) $(insn_mmx_SOURCES) insn_pclmulqdq.c \
Jakub Jelinek 79c245
 	$(insn_sse_SOURCES) $(insn_sse2_SOURCES) $(insn_sse3_SOURCES) \
Jakub Jelinek 79c245
-	$(insn_ssse3_SOURCES) jrcxz.c looper.c lzcnt64.c \
Jakub Jelinek 79c245
+	$(insn_ssse3_SOURCES) jrcxz.c looper.c loopnel.c lzcnt64.c \
Jakub Jelinek 79c245
 	nibz_bennee_mmap.c rcl-amd64.c redundantRexW.c sbbmisc.c \
Jakub Jelinek 79c245
 	shrld.c slahf-amd64.c smc1.c ssse3_misaligned.c xadd.c
Jakub Jelinek 79c245
 DIST_SOURCES = amd64locked.c bug127521-64.c bug132813-amd64.c \
Jakub Jelinek 79c245
@@ -211,9 +216,9 @@ DIST_SOURCES = amd64locked.c bug127521-6
Jakub Jelinek 79c245
 	$(insn_basic_SOURCES) $(insn_fpu_SOURCES) $(insn_mmx_SOURCES) \
Jakub Jelinek 79c245
 	insn_pclmulqdq.c $(insn_sse_SOURCES) $(insn_sse2_SOURCES) \
Jakub Jelinek 79c245
 	$(insn_sse3_SOURCES) $(insn_ssse3_SOURCES) jrcxz.c looper.c \
Jakub Jelinek 79c245
-	lzcnt64.c nibz_bennee_mmap.c rcl-amd64.c redundantRexW.c \
Jakub Jelinek 79c245
-	sbbmisc.c shrld.c slahf-amd64.c smc1.c ssse3_misaligned.c \
Jakub Jelinek 79c245
-	xadd.c
Jakub Jelinek 79c245
+	loopnel.c lzcnt64.c nibz_bennee_mmap.c rcl-amd64.c \
Jakub Jelinek 79c245
+	redundantRexW.c sbbmisc.c shrld.c slahf-amd64.c smc1.c \
Jakub Jelinek 79c245
+	ssse3_misaligned.c xadd.c
Jakub Jelinek 0332e1
 ETAGS = etags
Jakub Jelinek 0332e1
 CTAGS = ctags
Jakub Jelinek 0332e1
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
Jakub Jelinek 79c245
@@ -525,6 +530,7 @@ EXTRA_DIST = \
Jakub Jelinek 0332e1
 	insn_ssse3.stdout.exp insn_ssse3.stderr.exp insn_ssse3.vgtest \
Jakub Jelinek 0332e1
 	jrcxz.stderr.exp jrcxz.stdout.exp jrcxz.vgtest \
Jakub Jelinek 0332e1
 	looper.stderr.exp looper.stdout.exp looper.vgtest \
Jakub Jelinek 0332e1
+	loopnel.stderr.exp loopnel.stdout.exp loopnel.vgtest \
Jakub Jelinek 79c245
 	lzcnt64.stderr.exp lzcnt64.stdout.exp lzcnt64.vgtest \
Jakub Jelinek 0332e1
 	nibz_bennee_mmap.stderr.exp nibz_bennee_mmap.stdout.exp \
Jakub Jelinek 0332e1
 	nibz_bennee_mmap.vgtest \
Jakub Jelinek 79c245
@@ -660,6 +666,9 @@ jrcxz$(EXEEXT): $(jrcxz_OBJECTS) $(jrcxz
Jakub Jelinek 0332e1
 looper$(EXEEXT): $(looper_OBJECTS) $(looper_DEPENDENCIES) 
Jakub Jelinek 0332e1
 	@rm -f looper$(EXEEXT)
Jakub Jelinek 79c245
 	$(LINK) $(looper_OBJECTS) $(looper_LDADD) $(LIBS)
Jakub Jelinek 0332e1
+loopnel$(EXEEXT): $(loopnel_OBJECTS) $(loopnel_DEPENDENCIES) 
Jakub Jelinek 0332e1
+	@rm -f loopnel$(EXEEXT)
Jakub Jelinek 79c245
+	$(LINK) $(loopnel_OBJECTS) $(loopnel_LDADD) $(LIBS)
Jakub Jelinek 79c245
 lzcnt64$(EXEEXT): $(lzcnt64_OBJECTS) $(lzcnt64_DEPENDENCIES) 
Jakub Jelinek 79c245
 	@rm -f lzcnt64$(EXEEXT)
Jakub Jelinek 79c245
 	$(LINK) $(lzcnt64_OBJECTS) $(lzcnt64_LDADD) $(LIBS)
Jakub Jelinek 79c245
@@ -718,6 +727,7 @@ distclean-compile:
Jakub Jelinek 0332e1
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/insn_ssse3.Po@am__quote@
Jakub Jelinek 0332e1
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jrcxz.Po@am__quote@
Jakub Jelinek 0332e1
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/looper.Po@am__quote@
Jakub Jelinek 0332e1
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/loopnel.Po@am__quote@
Jakub Jelinek 79c245
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lzcnt64.Po@am__quote@
Jakub Jelinek 0332e1
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nibz_bennee_mmap.Po@am__quote@
Jakub Jelinek 0332e1
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rcl-amd64.Po@am__quote@