|
From: <sv...@va...> - 2006-05-21 01:02:35
|
Author: sewardj
Date: 2006-05-21 02:02:31 +0100 (Sun, 21 May 2006)
New Revision: 1620
Log:
A couple of IR simplification hacks for the amd64 front end, so as to
avoid false errors from memcheck. Analogous to some of the recent
bunch of commits to x86 front end.
Modified:
trunk/priv/guest-amd64/ghelpers.c
trunk/priv/ir/iropt.c
Modified: trunk/priv/guest-amd64/ghelpers.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/priv/guest-amd64/ghelpers.c 2006-05-19 23:09:03 UTC (rev 1619)
+++ trunk/priv/guest-amd64/ghelpers.c 2006-05-21 01:02:31 UTC (rev 1620)
@@ -1132,6 +1132,19 @@
mkU64(0)));
}
=20
+ if (isU64(cc_op, AMD64G_CC_OP_LOGICB) && isU64(cond, AMD64CondS)) =
{
+ /* this is an idiom gcc sometimes uses to find out if the top
+ bit of a byte register is set: eg testb %al,%al; js ..
+ Since it just depends on the top bit of the byte, extract
+ that bit and explicitly get rid of all the rest. This
+ helps memcheck avoid false positives in the case where any
+ of the other bits in the byte are undefined. */
+ /* byte and/or/xor, then S --> (UInt)result[7] */
+ return binop(Iop_And64,
+ binop(Iop_Shr64,cc_dep1,mkU8(7)),
+ mkU64(1));
+ }
+
/*---------------- INCB ----------------*/
=20
if (isU64(cc_op, AMD64G_CC_OP_INCB) && isU64(cond, AMD64CondLE)) {
Modified: trunk/priv/ir/iropt.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/priv/ir/iropt.c 2006-05-19 23:09:03 UTC (rev 1619)
+++ trunk/priv/ir/iropt.c 2006-05-21 01:02:31 UTC (rev 1620)
@@ -1419,6 +1419,17 @@
IRExpr_Const(IRConst_U8(1)));
} else
=20
+ /* Add64(t,t) =3D=3D> t << 1; rationale as for Add32(t,t) abov=
e. */
+ if (e->Iex.Binop.op =3D=3D Iop_Add64
+ && e->Iex.Binop.arg1->tag =3D=3D Iex_Tmp
+ && e->Iex.Binop.arg2->tag =3D=3D Iex_Tmp
+ && e->Iex.Binop.arg1->Iex.Tmp.tmp=20
+ =3D=3D e->Iex.Binop.arg2->Iex.Tmp.tmp) {
+ e2 =3D IRExpr_Binop(Iop_Shl64,
+ e->Iex.Binop.arg1,
+ IRExpr_Const(IRConst_U8(1)));
+ } else
+
/* Or64/Add64(x,0) =3D=3D> x */
if ((e->Iex.Binop.op =3D=3D Iop_Add64 || e->Iex.Binop.op =3D=3D=
Iop_Or64)
&& e->Iex.Binop.arg2->tag =3D=3D Iex_Const
|