Commit 3d735215 authored by Götz Lindenmaier's avatar Götz Lindenmaier
Browse files

confirm node

a new optimization in iropt
comments

[r1925]
parent 6474dc8e
......@@ -973,6 +973,9 @@ INLINE ir_node *new_r_Id (ir_graph *irg, ir_node *block,
INLINE ir_node *new_r_Bad (ir_graph *irg) {
return new_rd_Bad(irg);
}
INLINE ir_node *new_r_Confirm (ir_graph *irg, ir_node *block, ir_node *val, ir_node *bound, pn_Cmp cmp) {
return new_rd_Confirm (NULL, irg, block, val, bound, cmp);
}
INLINE ir_node *new_r_Unknown (ir_graph *irg) {
return new_rd_Unknown(irg);
}
......
......@@ -1179,6 +1179,8 @@ ir_node *new_rd_Tuple (dbg_info *db, ir_graph *irg, ir_node *block,
ir_node *new_rd_Id (dbg_info *db, ir_graph *irg, ir_node *block,
ir_node *val, ir_mode *mode);
ir_node *new_rd_Bad (ir_graph *irg);
ir_node *new_rd_Confirm (dbg_info *db, ir_graph *irg, ir_node *block,
ir_node *val, ir_node *bound, pn_Cmp cmp);
ir_node *new_rd_Unknown(ir_graph *irg);
ir_node *new_rd_CallBegin(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *callee);
ir_node *new_rd_EndReg (dbg_info *db, ir_graph *irg, ir_node *block);
......@@ -1273,6 +1275,8 @@ ir_node *new_r_Tuple (ir_graph *irg, ir_node *block,
ir_node *new_r_Id (ir_graph *irg, ir_node *block,
ir_node *val, ir_mode *mode);
ir_node *new_r_Bad (ir_graph *irg);
ir_node *new_r_Confirm (ir_graph *irg, ir_node *block,
ir_node *val, ir_node *bound, pn_Cmp cmp);
ir_node *new_r_Unknown(ir_graph *irg);
ir_node *new_r_CallBegin(ir_graph *irg, ir_node *block, ir_node *callee);
ir_node *new_r_EndReg (ir_graph *irg, ir_node *block);
......@@ -1342,6 +1346,7 @@ ir_node *new_d_defaultProj (dbg_info* db, ir_node *arg, long max_proj);
ir_node *new_d_Tuple (dbg_info* db, int arity, ir_node *in[]);
ir_node *new_d_Id (dbg_info* db, ir_node *val, ir_mode *mode);
ir_node *new_d_Bad (void);
ir_node *new_d_Confirm (dbg_info* db, ir_node *val, ir_node *bound, pn_Cmp cmp);
ir_node *new_d_Unknown(void);
ir_node *new_d_CallBegin(dbg_info *db, ir_node *callee);
ir_node *new_d_EndReg (dbg_info *db);
......@@ -1411,6 +1416,7 @@ ir_node *new_defaultProj (ir_node *arg, long max_proj);
ir_node *new_Tuple (int arity, ir_node *in[]);
ir_node *new_Id (ir_node *val, ir_mode *mode);
ir_node *new_Bad (void);
ir_node *new_Confirm (ir_node *val, ir_node *bound, pn_Cmp cmp);
ir_node *new_Unknown(void);
/*---------------------------------------------------------------------*/
......
......@@ -195,7 +195,9 @@ int get_mode_size_bytes(const ir_mode *mode);
/** Returns the alignment of values of the mode in bytes. */
int get_mode_align(const ir_mode *mode);
/** Returns the signess of a mode */
/** Returns the signess of a mode.
*
* Returns the signess of a mode: 1 if mode is signed. */
int get_mode_sign (const ir_mode *mode);
/** Returns the arithmetic of a mode */
......
......@@ -447,8 +447,8 @@ INLINE ir_node *get_Quot_mem (ir_node *node);
INLINE void set_Quot_mem (ir_node *node, ir_node *mem);
typedef enum {
pn_Quot_X_except, /**< Execution result if exception occured. */
pn_Quot_M, /**< Memory result. */
pn_Quot_X_except, /**< Execution result if exception occured. */
pn_Quot_res /**< Result of computation. */
} pn_Quot; /* Projection numbers for Quot. */
......@@ -460,8 +460,8 @@ INLINE ir_node *get_DivMod_mem (ir_node *node);
INLINE void set_DivMod_mem (ir_node *node, ir_node *mem);
typedef enum {
pn_DivMod_X_except, /**< Execution result if exception occured. */
pn_DivMod_M, /**< Memory result. */
pn_DivMod_X_except, /**< Execution result if exception occured. */
pn_DivMod_res_div, /**< Result of computation a / b. */
pn_DivMod_res_mod /**< Result of computation a % b. */
} pn_DivMod; /* Projection numbers for DivMod. */
......@@ -474,8 +474,8 @@ INLINE ir_node *get_Div_mem (ir_node *node);
INLINE void set_Div_mem (ir_node *node, ir_node *mem);
typedef enum {
pn_Div_X_except, /**< Execution result if exception occured. */
pn_Div_M, /**< Memory result. */
pn_Div_X_except, /**< Execution result if exception occured. */
pn_Div_res /**< Result of computation. */
} pn_Div; /* Projection numbers for Div. */
......@@ -487,8 +487,8 @@ INLINE ir_node *get_Mod_mem (ir_node *node);
INLINE void set_Mod_mem (ir_node *node, ir_node *mem);
typedef enum {
pn_Mod_X_except, /**< Execution result if exception occured. */
pn_Mod_M, /**< Memory result. */
pn_Mod_X_except, /**< Execution result if exception occured. */
pn_Mod_res /**< Result of computation. */
} pn_Mod; /* Projection numbers for Mod. */
......@@ -596,8 +596,8 @@ int get_Filter_n_cg_preds(ir_node *node);
ir_node * get_Filter_cg_pred(ir_node *node, int pos);
typedef enum {
pn_Load_X_except, /**< Execution result if exception occured. */
pn_Load_M, /**< Memory result. */
pn_Load_X_except, /**< Execution result if exception occured. */
pn_Load_res /**< Result of load operation. */
} pn_Load; /* Projection numbers for Load. */
......@@ -607,8 +607,8 @@ INLINE ir_node *get_Load_ptr (ir_node *node);
INLINE void set_Load_ptr (ir_node *node, ir_node *ptr);
typedef enum {
pn_Store_X_except, /**< Execution result if exception occured. */
pn_Store_M /**< Memory result. */
pn_Store_M, /**< Memory result. */
pn_Store_X_except /**< Execution result if exception occured. */
} pn_Store; /* Projection numbers for Store. */
INLINE ir_node *get_Store_mem (ir_node *node);
......@@ -619,8 +619,8 @@ INLINE ir_node *get_Store_value (ir_node *node);
INLINE void set_Store_value (ir_node *node, ir_node *value);
typedef enum {
pn_Alloc_X, /**< Execution result if exception occured. */
pn_Alloc_M, /**< Memory result. */
pn_Alloc_X_except, /**< Execution result if exception occured. */
pn_Alloc_res /**< Result of allocation. */
} pn_Alloc; /* Projection numbers for Alloc. */
......
......@@ -628,15 +628,44 @@ equivalent_node (ir_node *n)
return n;
} /* end equivalent_node() */
/* do node specific optimizations of nodes predecessors. */
static void
optimize_preds(ir_node *n) {
ir_node *a = NULL, *b = NULL;
/* get the operands we will work on for simple cases. */
if (is_binop(n)) {
a = get_binop_left(n);
b = get_binop_right(n);
} else if (is_unop(n)) {
a = get_unop_op(n);
}
switch (get_irn_opcode(n)) {
case iro_Cmp:
/* We don't want Cast as input to Cmp. */
if (get_irn_op(a) == op_Cast) {
a = get_Cast_op(a);
set_Cmp_left(n, a);
}
if (get_irn_op(b) == op_Cast) {
b = get_Cast_op(b);
set_Cmp_right(n, b);
}
break;
default: break;
} /* end switch */
}
/* tries several [inplace] [optimizing] transformations and returns an
equivalent node. The difference to equivalent_node is that these
transformations _do_ generate new nodes, and thus the old node must
not be freed even if the equivalent node isn't the old one. */
static ir_node *
transform_node (ir_node *n)
{
transform_node (ir_node *n) {
ir_node *a = NULL, *b;
tarval *ta, *tb;
......@@ -1099,6 +1128,8 @@ optimize_node (ir_node *n)
(get_irn_op(n) == op_Block) ) /* Flags tested local. */
n = equivalent_node (n);
optimize_preds(n); /* do node specific optimizations of nodes predecessors. */
/** common subexpression elimination **/
/* Checks whether n is already available. */
/* The block input is used to distinguish different subexpressions. Right
......@@ -1178,6 +1209,8 @@ optimize_in_place_2 (ir_node *n)
(get_irn_op(n) == op_Block) ) /* Flags tested local. */
n = equivalent_node (n);
optimize_preds(n); /* do node specific optimizations of nodes predecessors. */
/** common subexpression elimination **/
/* Checks whether n is already available. */
/* The block input is used to distinguish different subexpressions. Right
......
......@@ -120,11 +120,26 @@ vrfy_Proj_proj(ir_node *p, ir_graph *irg) {
break;
case iro_Load:
ASSERT_AND_RET(
((proj == 0 && mode == mode_M) ||
(proj == 1 && mode == mode_X) ||
(proj == 2 && mode_is_data(mode))),
"wrong Proj from Load", 0);
if (proj == pn_Load_res) {
ir_node *ptr = get_Load_ptr(pred);
entity *ent = NULL;
if (get_irn_op(ptr) == op_Sel) {
ent = get_Sel_entity(ptr);
} else if ((get_irn_op(ptr) == op_Const) &&
tarval_is_entity(get_Const_tarval(ptr))) {
ent = get_tarval_entity(get_Const_tarval(ptr));
}
if (ent)
ASSERT_AND_RET((mode == get_type_mode(get_entity_type(ent))),
"wrong data Proj from Load", 0);
else
ASSERT_AND_RET(mode_is_data(mode),
"wrong data Proj from Load", 0);
} else {
ASSERT_AND_RET(((proj == pn_Load_M && mode == mode_M) ||
(proj == pn_Load_X_except && mode == mode_X)),
"wrong Proj from Load", 0);
}
break;
case iro_Store:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment