]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Comparing a reg with itself produces a result which doesn't depend on
authorJulian Seward <jseward@acm.org>
Sat, 19 Aug 2006 18:31:53 +0000 (18:31 +0000)
committerJulian Seward <jseward@acm.org>
Sat, 19 Aug 2006 18:31:53 +0000 (18:31 +0000)
the contents of the reg.  Therefore remove the false dependency, which
has been known to cause memcheck to produce false errors for
xlc-compiled code.

git-svn-id: svn://svn.valgrind.org/vex/trunk@1640

VEX/priv/guest-ppc/toIR.c

index 296d8e8f1eb13be63fed9a46a0332c812b3cd51a..7fd3d71469547dfca1833fe854d53deb9b249061 100644 (file)
@@ -2936,6 +2936,12 @@ static Bool dis_int_cmp ( UInt theInstr )
       switch (opc2) {
       case 0x000: // cmp (Compare, PPC32 p367)
          DIP("cmp cr%u,%u,r%u,r%u\n", crfD, flag_L, rA_addr, rB_addr);
+         /* Comparing a reg with itself produces a result which
+            doesn't depend on the contents of the reg.  Therefore
+            remove the false dependency, which has been known to cause
+            memcheck to produce false errors. */
+        if (rA_addr == rB_addr)
+            a = b = mode64 ? mkU64(0) : mkU32(0);
          if (flag_L == 1) {
             putCR321(crfD, unop(Iop_64to8, binop(Iop_CmpORD64S, a, b)));
          } else {
@@ -2948,6 +2954,12 @@ static Bool dis_int_cmp ( UInt theInstr )
          
       case 0x020: // cmpl (Compare Logical, PPC32 p369)
          DIP("cmpl cr%u,%u,r%u,r%u\n", crfD, flag_L, rA_addr, rB_addr);
+         /* Comparing a reg with itself produces a result which
+            doesn't depend on the contents of the reg.  Therefore
+            remove the false dependency, which has been known to cause
+            memcheck to produce false errors. */
+        if (rA_addr == rB_addr)
+            a = b = mode64 ? mkU64(0) : mkU32(0);
          if (flag_L == 1) {
             putCR321(crfD, unop(Iop_64to8, binop(Iop_CmpORD64U, a, b)));
          } else {