|
From: <sv...@va...> - 2012-02-15 00:48:10
|
Author: florian
Date: 2012-02-15 00:43:36 +0000 (Wed, 15 Feb 2012)
New Revision: 2248
Log:
In fold_Expr use a switch instead of an if-chain for clarity and
efficiency.
Modified:
trunk/priv/ir_opt.c
Modified: trunk/priv/ir_opt.c
===================================================================
--- trunk/priv/ir_opt.c 2012-02-14 21:34:56 UTC (rev 2247)
+++ trunk/priv/ir_opt.c 2012-02-15 00:43:36 UTC (rev 2248)
@@ -1120,10 +1120,11 @@
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 @@
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 @@
break;
}
}
- }
+ break;
- /* Mux0X */
- if (e->tag == Iex_Mux0X) {
+ case Iex_Mux0X:
+ /* Mux0X */
+
/* is the discriminant is a constant? */
if (e->Iex.Mux0X.cond->tag == Iex_Const) {
Bool zero;
@@ -1887,6 +1890,11 @@
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)'. */
|