From: Julian Seward Date: Thu, 3 Apr 2014 13:48:21 +0000 (+0000) Subject: Add a couple more constant folding rules for vectors. X-Git-Tag: svn/VALGRIND_3_10_1^2~126 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9920004951a2aedfcc1432acad5b83650dcba3e5;p=thirdparty%2Fvalgrind.git Add a couple more constant folding rules for vectors. git-svn-id: svn://svn.valgrind.org/vex/trunk@2844 --- diff --git a/VEX/priv/ir_opt.c b/VEX/priv/ir_opt.c index 1be5303c8c..03a06e3054 100644 --- a/VEX/priv/ir_opt.c +++ b/VEX/priv/ir_opt.c @@ -1251,7 +1251,8 @@ static IRExpr* mkZeroOfPrimopResultType ( IROp op ) case Iop_And64: case Iop_Sub64: case Iop_Xor64: return IRExpr_Const(IRConst_U64(0)); - case Iop_XorV128: return IRExpr_Const(IRConst_V128(0)); + case Iop_XorV128: + case Iop_AndV128: return IRExpr_Const(IRConst_V128(0)); default: vpanic("mkZeroOfPrimopResultType: bad primop"); } } @@ -2150,6 +2151,13 @@ static IRExpr* fold_Expr ( IRExpr** env, IRExpr* e ) break; } break; + case Iop_Sub8x16: + /* Sub8x16(x,0) ==> x */ + if (isZeroV128(e->Iex.Binop.arg2)) { + e2 = e->Iex.Binop.arg1; + break; + } + break; case Iop_And64: case Iop_And32: @@ -2185,13 +2193,18 @@ static IRExpr* fold_Expr ( IRExpr** env, IRExpr* e ) e2 = e->Iex.Binop.arg1; break; } - if (/* could handle other And cases here too, but so - far not */ - e->Iex.Binop.op == Iop_And64 + /* Deal with either arg zero. Could handle other And + cases here too. */ + if (e->Iex.Binop.op == Iop_And64 && (isZeroU64(e->Iex.Binop.arg1) || isZeroU64(e->Iex.Binop.arg2))) { e2 = mkZeroOfPrimopResultType(e->Iex.Binop.op); break; + } else if (e->Iex.Binop.op == Iop_AndV128 + && (isZeroV128(e->Iex.Binop.arg1) + || isZeroV128(e->Iex.Binop.arg2))) { + e2 = mkZeroOfPrimopResultType(e->Iex.Binop.op); + break; } break;