]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
amd64: add a couple more spec cases: NLE after SUBL, and NZ after LOGICB.
authorJulian Seward <jseward@acm.org>
Fri, 15 Jan 2010 09:54:55 +0000 (09:54 +0000)
committerJulian Seward <jseward@acm.org>
Fri, 15 Jan 2010 09:54:55 +0000 (09:54 +0000)
x86: add commented out (ATC) spec case for C flag after SMULL.

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

VEX/priv/guest_amd64_helpers.c
VEX/priv/guest_x86_helpers.c

index 441357e01f175837635c2132d72c1224e1100f5b..e087650cf0708ef89be00095cd8a38734499372d 100644 (file)
@@ -994,6 +994,17 @@ IRExpr* guest_amd64_spechelper ( HChar* function_name,
                            binop(Iop_Shl64,cc_dep1,mkU8(32)),
                            binop(Iop_Shl64,cc_dep2,mkU8(32))));
 
+      }
+      if (isU64(cc_op, AMD64G_CC_OP_SUBL) && isU64(cond, AMD64CondNLE)) {
+         /* long sub/cmp, then NLE (signed greater than) 
+            --> test !(dst <=s src)
+            --> test (dst >s src)
+            --> test (src <s dst) */
+         return unop(Iop_1Uto64,
+                     binop(Iop_CmpLT64S,
+                           binop(Iop_Shl64,cc_dep2,mkU8(32)),
+                           binop(Iop_Shl64,cc_dep1,mkU8(32))));
+
       }
 
       if (isU64(cc_op, AMD64G_CC_OP_SUBL) && isU64(cond, AMD64CondBE)) {
@@ -1155,6 +1166,12 @@ IRExpr* guest_amd64_spechelper ( HChar* function_name,
                      binop(Iop_CmpEQ64, binop(Iop_And64,cc_dep1,mkU64(255)), 
                                         mkU64(0)));
       }
+      if (isU64(cc_op, AMD64G_CC_OP_LOGICB) && isU64(cond, AMD64CondNZ)) {
+         /* byte and/or/xor, then NZ --> test dst!=0 */
+         return unop(Iop_1Uto64,
+                     binop(Iop_CmpNE64, binop(Iop_And64,cc_dep1,mkU64(255)), 
+                                        mkU64(0)));
+      }
 
       if (isU64(cc_op, AMD64G_CC_OP_LOGICB) && isU64(cond, AMD64CondS)) {
          /* this is an idiom gcc sometimes uses to find out if the top
index bec1dc3f3f0a07d223338c45225946d53fb812e2..d901d40464b1245e26fcea867b424411044b856f 100644 (file)
@@ -1272,6 +1272,22 @@ IRExpr* guest_x86_spechelper ( HChar* function_name,
                            binop(Iop_Add32, cc_dep1, cc_dep2), 
                            cc_dep1));
       }
+      // ATC, requires verification, no test case known
+      //if (isU32(cc_op, X86G_CC_OP_SMULL)) {
+      //   /* C after signed widening multiply denotes the case where
+      //      the top half of the result isn't simply the sign extension
+      //      of the bottom half (iow the result doesn't fit completely
+      //      in the bottom half).  Hence: 
+      //        C = hi-half(dep1 x dep2) != lo-half(dep1 x dep2) >>s 31 
+      //      where 'x' denotes signed widening multiply.*/
+      //   return 
+      //      unop(Iop_1Uto32,
+      //           binop(Iop_CmpNE32, 
+      //                 unop(Iop_64HIto32,
+      //                      binop(Iop_MullS32, cc_dep1, cc_dep2)),
+      //                 binop(Iop_Sar32,
+      //                       binop(Iop_Mul32, cc_dep1, cc_dep2), mkU8(31)) ));
+      //}
 #     if 0
       if (cc_op->tag == Iex_Const) {
          vex_printf("CFLAG "); ppIRExpr(cc_op); vex_printf("\n");