vex: r3342 - in /trunk/priv: host_mips_defs.c host_mips_isel.c

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

vex: r3342 - in /trunk/priv: host_mips_defs.c host_mips_isel.c

svn-2
Author: petarj
Date: Mon Apr  3 15:30:13 2017
New Revision: 3342

Log:
mips64: sign-extend results from dirty helper

Values returned from the dirty helper may not be sign-extended, so let's
make sure the values get passed as sign-extended for Ity_I32, Ity_I16, and
Ity_I8 cases.
At the same time, we can remove now redundant sign-extensions introduced in
VEX r3304.

This fixes memcheck/test/bug340392 on some MIPS64 boards.

Patch by Aleksandar Rikalo.


Modified:
    trunk/priv/host_mips_defs.c
    trunk/priv/host_mips_isel.c

Modified: trunk/priv/host_mips_defs.c
==============================================================================
--- trunk/priv/host_mips_defs.c (original)
+++ trunk/priv/host_mips_defs.c Mon Apr  3 15:30:13 2017
@@ -1584,15 +1584,8 @@
          addHRegUse(u, HRmWrite, i->Min.Shft.dst);
          return;
       case Min_Cmp:
-         if (i->Min.Cmp.sz32 && mode64 &&
-            (i->Min.Cmp.cond != MIPScc_EQ) &&
-            (i->Min.Cmp.cond != MIPScc_NE)) {
-            addHRegUse(u, HRmModify, i->Min.Cmp.srcL);
-            addHRegUse(u, HRmModify, i->Min.Cmp.srcR);
-         } else {
-            addHRegUse(u, HRmRead, i->Min.Cmp.srcL);
-            addHRegUse(u, HRmRead, i->Min.Cmp.srcR);
-         }
+         addHRegUse(u, HRmRead, i->Min.Cmp.srcL);
+         addHRegUse(u, HRmRead, i->Min.Cmp.srcR);
          addHRegUse(u, HRmWrite, i->Min.Cmp.dst);
          return;
       case Min_Unary:
@@ -2761,68 +2754,35 @@
          UInt r_srcL = iregNo(i->Min.Cmp.srcL, mode64);
          UInt r_srcR = iregNo(i->Min.Cmp.srcR, mode64);
          UInt r_dst = iregNo(i->Min.Cmp.dst, mode64);
-         Bool sz32 = i->Min.Cmp.sz32;
 
          switch (i->Min.Cmp.cond) {
             case MIPScc_EQ:
                /* xor r_dst, r_srcL, r_srcR
                   sltiu r_dst, r_dst, 1 */
                p = mkFormR(p, 0, r_srcL, r_srcR, r_dst, 0, 38);
-               if (mode64 && sz32) {
-                  /* sll r_dst, r_dst, 0 */
-                  p = mkFormS(p, 0, r_dst, 0, r_dst, 0, 0);
-               }
                p = mkFormI(p, 11, r_dst, r_dst, 1);
                break;
             case MIPScc_NE:
                /* xor r_dst, r_srcL, r_srcR
                   sltu r_dst, zero, r_dst */
                p = mkFormR(p, 0, r_srcL, r_srcR, r_dst, 0, 38);
-               if (mode64 && sz32) {
-                  /* sll r_dst, r_dst, 0 */
-                  p = mkFormS(p, 0, r_dst, 0, r_dst, 0, 0);
-               }
                p = mkFormR(p, 0, 0, r_dst, r_dst, 0, 43);
                break;
             case MIPScc_LT:
-               if (mode64 && sz32) {
-                  /* sll r_srcL, r_srcL, 0
-                     sll r_srcR, r_srcR, 0 */
-                  p = mkFormS(p, 0, r_srcL, 0, r_srcL, 0, 0);
-                  p = mkFormS(p, 0, r_srcR, 0, r_srcR, 0, 0);
-               }
                /* slt r_dst, r_srcL, r_srcR */
                p = mkFormR(p, 0, r_srcL, r_srcR, r_dst, 0, 42);
                break;
             case MIPScc_LO:
-               if (mode64 && sz32) {
-                  /* sll r_srcL, r_srcL, 0
-                     sll r_srcR, r_srcR, 0 */
-                  p = mkFormS(p, 0, r_srcL, 0, r_srcL, 0, 0);
-                  p = mkFormS(p, 0, r_srcR, 0, r_srcR, 0, 0);
-               }
                /* sltu r_dst, r_srcL, r_srcR */
                p = mkFormR(p, 0, r_srcL, r_srcR, r_dst, 0, 43);
                break;
             case MIPScc_LE:
-               if (mode64 && sz32) {
-                  /* sll r_srcL, r_srcL, 0
-                     sll r_srcR, r_srcR, 0 */
-                  p = mkFormS(p, 0, r_srcL, 0, r_srcL, 0, 0);
-                  p = mkFormS(p, 0, r_srcR, 0, r_srcR, 0, 0);
-               }
                /* slt r_dst, r_srcR, r_srcL
                   xori r_dst, r_dst, 1 */
                p = mkFormR(p, 0, r_srcR, r_srcL, r_dst, 0, 42);
                p = mkFormI(p, 14, r_dst, r_dst, 1);
                break;
             case MIPScc_LS:
-               if (mode64 && sz32) {
-                  /* sll r_srcL, r_srcL, 0
-                     sll r_srcR, r_srcR, 0 */
-                  p = mkFormS(p, 0, r_srcL, 0, r_srcL, 0, 0);
-                  p = mkFormS(p, 0, r_srcR, 0, r_srcR, 0, 0);
-               }
                /* sltu r_dst, rsrcR, r_srcL
                   xori r_dsr, r_dst, 1 */
                p = mkFormR(p, 0, r_srcR, r_srcL, r_dst, 0, 43);

Modified: trunk/priv/host_mips_isel.c
==============================================================================
--- trunk/priv/host_mips_isel.c (original)
+++ trunk/priv/host_mips_isel.c Mon Apr  3 15:30:13 2017
@@ -3843,7 +3843,9 @@
                /* The returned value is in $v0.  Park it in the register
                   associated with tmp. */
                HReg r_dst = lookupIRTemp(env, d->tmp);
-               addInstr(env, mk_iMOVds_RR(r_dst, hregMIPS_GPR2(mode64)));
+               addInstr(env, MIPSInstr_Shft(Mshft_SLL, True, r_dst,
+                                            hregMIPS_GPR2(mode64),
+                                            MIPSRH_Imm(False, 0)));
                vassert(rloc.pri == RLPri_Int);
                vassert(addToSp == 0);
                return;


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Valgrind-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/valgrind-developers
Loading...