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