]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
In fold_Expr use a switch instead of an if-chain for clarity and
authorFlorian Krohm <florian@eich-krohm.de>
Wed, 15 Feb 2012 00:43:36 +0000 (00:43 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Wed, 15 Feb 2012 00:43:36 +0000 (00:43 +0000)
efficiency.

git-svn-id: svn://svn.valgrind.org/vex/trunk@2248

VEX/priv/ir_opt.c

index 78ac6ff4a1fe0bd13d6b5da9ff9dfa31226210dd..d5712598e7c81aa6a7ed49db1a2336bb097edf66 100644 (file)
@@ -1120,10 +1120,11 @@ static IRExpr* fold_Expr ( IRExpr** env, IRExpr* e )
    Int     shift;
    IRExpr* e2 = e; /* e2 is the result of folding e, if possible */
 
-   /* UNARY ops */
-   if (e->tag == Iex_Unop
-       && e->Iex.Unop.arg->tag == Iex_Const) {
-      switch (e->Iex.Unop.op) {
+   switch (e->tag) {
+   case Iex_Unop:
+      /* UNARY ops */
+      if (e->Iex.Unop.arg->tag == Iex_Const) {
+         switch (e->Iex.Unop.op) {
          case Iop_1Uto8:
             e2 = IRExpr_Const(IRConst_U8(toUChar(
                     e->Iex.Unop.arg->Iex.Const.con->Ico.U1
@@ -1368,10 +1369,11 @@ static IRExpr* fold_Expr ( IRExpr** env, IRExpr* e )
          default: 
             goto unhandled;
       }
-   }
+      }
+      break;
 
-   /* BINARY ops */
-   if (e->tag == Iex_Binop) {
+   case Iex_Binop:
+      /* BINARY ops */
       if (e->Iex.Binop.arg1->tag == Iex_Const
           && e->Iex.Binop.arg2->tag == Iex_Const) {
          /* cases where both args are consts */
@@ -1868,10 +1870,11 @@ static IRExpr* fold_Expr ( IRExpr** env, IRExpr* e )
                break;
          }
       }
-   }
+      break;
+
+   case Iex_Mux0X:
+      /* Mux0X */
 
-   /* Mux0X */
-   if (e->tag == Iex_Mux0X) {
       /* is the discriminant is a constant? */
       if (e->Iex.Mux0X.cond->tag == Iex_Const) {
          Bool zero;
@@ -1887,6 +1890,11 @@ static IRExpr* fold_Expr ( IRExpr** env, IRExpr* e )
                       e->Iex.Mux0X.exprX)) {
          e2 = e->Iex.Mux0X.expr0;
       }
+      break;
+
+   default:
+      /* not considered */
+      break;
    }
 
    /* Show cases where we've found but not folded 'op(t,t)'. */