From: Florian Krohm Date: Wed, 1 Oct 2025 12:19:13 +0000 (+0000) Subject: VEX: Remove algebraic simplification for shift IROps. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=09f6162dd7ca1e60ceeb6e7fac30a1f9a8cf6641;p=thirdparty%2Fvalgrind.git VEX: Remove algebraic simplification for shift IROps. Shl/Shr/Sar(0,x) ==> 0 Don't. Because doing so removes the undefined behaviour in case the shift amount is out of range. This is also consistent with what constant folding does in this case, namely, passing the undefined behaviour down the VEX pipeline. --- diff --git a/VEX/priv/ir_opt.c b/VEX/priv/ir_opt.c index 4b07b27fc..1b21c8e3e 100644 --- a/VEX/priv/ir_opt.c +++ b/VEX/priv/ir_opt.c @@ -2623,13 +2623,6 @@ static IRExpr* fold_Expr_WRK ( IRExpr** env, IRExpr* e ) e2 = e->Iex.Binop.arg1; break; } - /* Shl8/Shl16/Shl32/Shl64(0,x) ==> 0 - Shr8/Shr16/Shr32/Shr64(0,x) ==> 0 - Sar8/Sar16/Sar32/Sar64(0,x) ==> 0 */ - if (isZeroU(e->Iex.Binop.arg1)) { - e2 = e->Iex.Binop.arg1; - break; - } break; case Iop_Or1: