|
|
4507b4 |
commit 595341b150312d2407bd43304449bf39ec3e1fa8
|
|
|
4507b4 |
Author: Julian Seward <jseward@acm.org>
|
|
|
4507b4 |
Date: Sat Nov 13 19:59:07 2021 +0100
|
|
|
4507b4 |
|
|
|
4507b4 |
amd64 front end: add more spec rules:
|
|
|
4507b4 |
|
|
|
4507b4 |
S after SHRQ
|
|
|
4507b4 |
Z after SHLQ
|
|
|
4507b4 |
NZ after SHLQ
|
|
|
4507b4 |
Z after SHLL
|
|
|
4507b4 |
S after SHLL
|
|
|
4507b4 |
|
|
|
4507b4 |
The lack of at least one of these was observed to cause occasional false
|
|
|
4507b4 |
positives in Memcheck.
|
|
|
4507b4 |
|
|
|
4507b4 |
Plus add commented-out cases so as to complete the set of 12 rules
|
|
|
4507b4 |
{Z,NZ,S,NS} after {SHRQ,SHLQ,SHLL}. The commented-out ones are commented
|
|
|
4507b4 |
out because I so far didn't find any use cases for them.
|
|
|
4507b4 |
|
|
|
4507b4 |
diff --git a/VEX/priv/guest_amd64_helpers.c b/VEX/priv/guest_amd64_helpers.c
|
|
|
4507b4 |
index 9d61e7a0f..ba71c1b62 100644
|
|
|
4507b4 |
--- a/VEX/priv/guest_amd64_helpers.c
|
|
|
4507b4 |
+++ b/VEX/priv/guest_amd64_helpers.c
|
|
|
4507b4 |
@@ -1823,16 +1823,26 @@ IRExpr* guest_amd64_spechelper ( const HChar* function_name,
|
|
|
4507b4 |
/*---------------- SHRQ ----------------*/
|
|
|
4507b4 |
|
|
|
4507b4 |
if (isU64(cc_op, AMD64G_CC_OP_SHRQ) && isU64(cond, AMD64CondZ)) {
|
|
|
4507b4 |
- /* SHRQ, then Z --> test dep1 == 0 */
|
|
|
4507b4 |
+ /* SHRQ, then Z --> test result[63:0] == 0 */
|
|
|
4507b4 |
return unop(Iop_1Uto64,
|
|
|
4507b4 |
binop(Iop_CmpEQ64, cc_dep1, mkU64(0)));
|
|
|
4507b4 |
}
|
|
|
4507b4 |
if (isU64(cc_op, AMD64G_CC_OP_SHRQ) && isU64(cond, AMD64CondNZ)) {
|
|
|
4507b4 |
- /* SHRQ, then NZ --> test dep1 != 0 */
|
|
|
4507b4 |
+ /* SHRQ, then NZ --> test result[63:0] != 0 */
|
|
|
4507b4 |
return unop(Iop_1Uto64,
|
|
|
4507b4 |
binop(Iop_CmpNE64, cc_dep1, mkU64(0)));
|
|
|
4507b4 |
}
|
|
|
4507b4 |
|
|
|
4507b4 |
+ if (isU64(cc_op, AMD64G_CC_OP_SHRQ) && isU64(cond, AMD64CondS)) {
|
|
|
4507b4 |
+ /* SHRQ, then S --> (ULong)result[63] (result is in dep1) */
|
|
|
4507b4 |
+ return binop(Iop_Shr64, cc_dep1, mkU8(63));
|
|
|
4507b4 |
+ }
|
|
|
4507b4 |
+ // No known test case for this, hence disabled:
|
|
|
4507b4 |
+ //if (isU64(cc_op, AMD64G_CC_OP_SHRQ) && isU64(cond, AMD64CondNS)) {
|
|
|
4507b4 |
+ // /* SHRQ, then NS --> (ULong) ~ result[63] */
|
|
|
4507b4 |
+ // vassert(0);
|
|
|
4507b4 |
+ //}
|
|
|
4507b4 |
+
|
|
|
4507b4 |
/*---------------- SHRL ----------------*/
|
|
|
4507b4 |
|
|
|
4507b4 |
if (isU64(cc_op, AMD64G_CC_OP_SHRL) && isU64(cond, AMD64CondZ)) {
|
|
|
4507b4 |
@@ -1881,6 +1891,52 @@ IRExpr* guest_amd64_spechelper ( const HChar* function_name,
|
|
|
4507b4 |
// mkU32(0)));
|
|
|
4507b4 |
//}
|
|
|
4507b4 |
|
|
|
4507b4 |
+ /*---------------- SHLQ ----------------*/
|
|
|
4507b4 |
+
|
|
|
4507b4 |
+ if (isU64(cc_op, AMD64G_CC_OP_SHLQ) && isU64(cond, AMD64CondZ)) {
|
|
|
4507b4 |
+ /* SHLQ, then Z --> test dep1 == 0 */
|
|
|
4507b4 |
+ return unop(Iop_1Uto64,
|
|
|
4507b4 |
+ binop(Iop_CmpEQ64, cc_dep1, mkU64(0)));
|
|
|
4507b4 |
+ }
|
|
|
4507b4 |
+ if (isU64(cc_op, AMD64G_CC_OP_SHLQ) && isU64(cond, AMD64CondNZ)) {
|
|
|
4507b4 |
+ /* SHLQ, then NZ --> test dep1 != 0 */
|
|
|
4507b4 |
+ return unop(Iop_1Uto64,
|
|
|
4507b4 |
+ binop(Iop_CmpNE64, cc_dep1, mkU64(0)));
|
|
|
4507b4 |
+ }
|
|
|
4507b4 |
+
|
|
|
4507b4 |
+ //if (isU64(cc_op, AMD64G_CC_OP_SHLQ) && isU64(cond, AMD64CondS)) {
|
|
|
4507b4 |
+ // /* SHLQ, then S --> (ULong)result[63] */
|
|
|
4507b4 |
+ // vassert(0);
|
|
|
4507b4 |
+ //}
|
|
|
4507b4 |
+ //if (isU64(cc_op, AMD64G_CC_OP_SHLQ) && isU64(cond, AMD64CondNS)) {
|
|
|
4507b4 |
+ // /* SHLQ, then NS --> (ULong) ~ result[63] */
|
|
|
4507b4 |
+ // vassert(0);
|
|
|
4507b4 |
+ //}
|
|
|
4507b4 |
+
|
|
|
4507b4 |
+ /*---------------- SHLL ----------------*/
|
|
|
4507b4 |
+
|
|
|
4507b4 |
+ if (isU64(cc_op, AMD64G_CC_OP_SHLL) && isU64(cond, AMD64CondZ)) {
|
|
|
4507b4 |
+ /* SHLL, then Z --> test result[31:0] == 0 */
|
|
|
4507b4 |
+ return unop(Iop_1Uto64,
|
|
|
4507b4 |
+ binop(Iop_CmpEQ32, unop(Iop_64to32, cc_dep1),
|
|
|
4507b4 |
+ mkU32(0)));
|
|
|
4507b4 |
+ }
|
|
|
4507b4 |
+ //if (isU64(cc_op, AMD64G_CC_OP_SHLL) && isU64(cond, AMD64CondNZ)) {
|
|
|
4507b4 |
+ // /* SHLL, then NZ --> test dep1 != 0 */
|
|
|
4507b4 |
+ // vassert(0);
|
|
|
4507b4 |
+ //}
|
|
|
4507b4 |
+
|
|
|
4507b4 |
+ if (isU64(cc_op, AMD64G_CC_OP_SHLL) && isU64(cond, AMD64CondS)) {
|
|
|
4507b4 |
+ /* SHLL, then S --> (ULong)result[31] */
|
|
|
4507b4 |
+ return binop(Iop_And64,
|
|
|
4507b4 |
+ binop(Iop_Shr64, cc_dep1, mkU8(31)),
|
|
|
4507b4 |
+ mkU64(1));
|
|
|
4507b4 |
+ }
|
|
|
4507b4 |
+ //if (isU64(cc_op, AMD64G_CC_OP_SHLL) && isU64(cond, AMD64CondNS)) {
|
|
|
4507b4 |
+ // /* SHLL, then NS --> (ULong) ~ result[31] */
|
|
|
4507b4 |
+ // vassert(0);
|
|
|
4507b4 |
+ //}
|
|
|
4507b4 |
+
|
|
|
4507b4 |
/*---------------- COPY ----------------*/
|
|
|
4507b4 |
/* This can happen, as a result of amd64 FP compares: "comisd ... ;
|
|
|
4507b4 |
jbe" for example. */
|