]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
VEX: Remove algebraic simplification for shift IROps.
authorFlorian Krohm <flo2030@eich-krohm.de>
Wed, 1 Oct 2025 12:19:13 +0000 (12:19 +0000)
committerFlorian Krohm <flo2030@eich-krohm.de>
Wed, 1 Oct 2025 12:19:13 +0000 (12:19 +0000)
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.

VEX/priv/ir_opt.c

index 4b07b27fc46c5db41ec3d8db4520a6bff20884c5..1b21c8e3ecd7bc228930d45161005d7d7ee5737f 100644 (file)
@@ -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: