]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add a constant folding rule for MullS32.
authorJulian Seward <jseward@acm.org>
Tue, 1 Mar 2005 10:19:23 +0000 (10:19 +0000)
committerJulian Seward <jseward@acm.org>
Tue, 1 Mar 2005 10:19:23 +0000 (10:19 +0000)
git-svn-id: svn://svn.valgrind.org/vex/trunk@991

VEX/priv/ir/iropt.c

index 52daf92646178d676e83b72f11b9b699d3fc6df5..ac5dba839a0ffd2f8b1cd3697301c614c887ba99 100644 (file)
@@ -1047,6 +1047,19 @@ static IRExpr* fold_Expr ( IRExpr* e )
                        (e->Iex.Binop.arg1->Iex.Const.con->Ico.U32
                         * e->Iex.Binop.arg2->Iex.Const.con->Ico.U32)));
                break;
+            case Iop_MullS32: {
+               /* very paranoid */
+               UInt  u32a = e->Iex.Binop.arg1->Iex.Const.con->Ico.U32;
+               UInt  u32b = e->Iex.Binop.arg2->Iex.Const.con->Ico.U32;
+               Int   s32a = (Int)u32a;
+               Int   s32b = (Int)u32b;
+               Long  s64a = (Long)s32a;
+               Long  s64b = (Long)s32b;
+               Long  sres = s64a * s64b;
+               ULong ures = (ULong)sres;
+               e2 = IRExpr_Const(IRConst_U64(ures));
+               break;
+            }
 
             /* -- Shl -- */
             case Iop_Shl32: