]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add a couple more constant folding rules.
authorJulian Seward <jseward@acm.org>
Fri, 12 Nov 2004 00:13:21 +0000 (00:13 +0000)
committerJulian Seward <jseward@acm.org>
Fri, 12 Nov 2004 00:13:21 +0000 (00:13 +0000)
git-svn-id: svn://svn.valgrind.org/vex/trunk@547

VEX/priv/ir/iropt.c

index 9f692c91ca8d8927b6912327d083862592e70632..b9372e2e2fa009a7ad128e592a2ec960234f3085 100644 (file)
@@ -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(