From: Julian Seward Date: Fri, 12 Nov 2004 00:13:21 +0000 (+0000) Subject: Add a couple more constant folding rules. X-Git-Tag: svn/VALGRIND_3_0_1^2~787 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e77e2a01f6c1cbdfebce7a55120c5a8e36698ae0;p=thirdparty%2Fvalgrind.git Add a couple more constant folding rules. git-svn-id: svn://svn.valgrind.org/vex/trunk@547 --- diff --git a/VEX/priv/ir/iropt.c b/VEX/priv/ir/iropt.c index 9f692c91ca..b9372e2e2f 100644 --- a/VEX/priv/ir/iropt.c +++ b/VEX/priv/ir/iropt.c @@ -342,6 +342,13 @@ static Bool sameIRTemps ( IRExpr* e1, IRExpr* e2 ) && e1->Iex.Tmp.tmp == e2->Iex.Tmp.tmp; } +static Bool notBool ( Bool b ) +{ + if (b == True) return False; + if (b == False) return True; + vpanic("notBool"); +} + static IRExpr* fold_Expr ( IRExpr* e ) { Int shift; @@ -415,6 +422,11 @@ static IRExpr* fold_Expr ( IRExpr* e ) ~ (e->Iex.Unop.arg->Iex.Const.con->Ico.U8))); break; + case Iop_Not1: + e2 = IRExpr_Const(IRConst_Bit( + notBool(e->Iex.Unop.arg->Iex.Const.con->Ico.Bit))); + break; + default: goto unhandled; } @@ -555,11 +567,17 @@ static IRExpr* fold_Expr ( IRExpr* e ) ((Int)(e->Iex.Binop.arg1->Iex.Const.con->Ico.U32) <= (Int)(e->Iex.Binop.arg2->Iex.Const.con->Ico.U32)))); break; + case Iop_CmpLT32S: e2 = IRExpr_Const(IRConst_Bit( ((Int)(e->Iex.Binop.arg1->Iex.Const.con->Ico.U32) < (Int)(e->Iex.Binop.arg2->Iex.Const.con->Ico.U32)))); break; + case Iop_CmpLT32U: + e2 = IRExpr_Const(IRConst_Bit( + ((UInt)(e->Iex.Binop.arg1->Iex.Const.con->Ico.U32) + < (UInt)(e->Iex.Binop.arg2->Iex.Const.con->Ico.U32)))); + break; case Iop_32HLto64: e2 = IRExpr_Const(IRConst_U64(