Commit 9785090d authored by yb9976's avatar yb9976
Browse files

Added commutative optimization variants.

parent 6ae22fa1
......@@ -3143,19 +3143,33 @@ static ir_node *transform_node_And(ir_node *n)
/* Cmp(a==b) and Cmp(c==d) can be optimized to Cmp((a^b)|(c^d)==0) */
if (a_relation == b_relation && a_relation == ir_relation_equal
&& !mode_is_float(get_irn_mode(a_left))
&& !mode_is_float(get_irn_mode(b_left))
&& values_in_mode(get_irn_mode(b_left), get_irn_mode(a_left))) {
dbg_info *dbgi = get_irn_dbg_info(n);
ir_node *block = get_nodes_block(n);
ir_mode *a_mode = get_irn_mode(a_left);
ir_mode *b_mode = get_irn_mode(b_left);
ir_node *xora = new_rd_Eor(dbgi, block, a_left, a_right, a_mode);
ir_node *xorb = new_rd_Eor(dbgi, block, b_left, b_right, b_mode);
ir_node *conv = new_rd_Conv(dbgi, block, xorb, a_mode);
ir_node *or = new_rd_Or(dbgi, block, xora, conv, a_mode);
ir_graph *irg = get_irn_irg(n);
ir_node *zero = create_zero_const(irg, a_mode);
return new_rd_Cmp(dbgi, block, or, zero, ir_relation_equal);
&& !mode_is_float(get_irn_mode(b_left))) {
if (values_in_mode(get_irn_mode(a_left), get_irn_mode(b_left))) {
dbg_info *dbgi = get_irn_dbg_info(n);
ir_node *block = get_nodes_block(n);
ir_mode *a_mode = get_irn_mode(a_left);
ir_mode *b_mode = get_irn_mode(b_left);
ir_node *xora = new_rd_Eor(dbgi, block, a_left, a_right, a_mode);
ir_node *xorb = new_rd_Eor(dbgi, block, b_left, b_right, b_mode);
ir_node *conv = new_rd_Conv(dbgi, block, xora, b_mode);
ir_node *or = new_rd_Or(dbgi, block, conv, xorb, b_mode);
ir_graph *irg = get_irn_irg(n);
ir_node *zero = create_zero_const(irg, b_mode);
return new_rd_Cmp(dbgi, block, or, zero, ir_relation_equal);
}
if (values_in_mode(get_irn_mode(b_left), get_irn_mode(a_left))) {
dbg_info *dbgi = get_irn_dbg_info(n);
ir_node *block = get_nodes_block(n);
ir_mode *a_mode = get_irn_mode(a_left);
ir_mode *b_mode = get_irn_mode(b_left);
ir_node *xora = new_rd_Eor(dbgi, block, a_left, a_right, a_mode);
ir_node *xorb = new_rd_Eor(dbgi, block, b_left, b_right, b_mode);
ir_node *conv = new_rd_Conv(dbgi, block, xorb, a_mode);
ir_node *or = new_rd_Or(dbgi, block, xora, conv, a_mode);
ir_graph *irg = get_irn_irg(n);
ir_node *zero = create_zero_const(irg, a_mode);
return new_rd_Cmp(dbgi, block, or, zero, ir_relation_equal);
}
}
}
......@@ -4910,19 +4924,33 @@ static ir_node *transform_node_Or(ir_node *n)
/* Cmp(a!=b) or Cmp(c!=d) => Cmp((a^b)|(c^d) != 0) */
if (is_cmp_unequal(a) && is_cmp_unequal(b)
&& !mode_is_float(get_irn_mode(a_left))
&& !mode_is_float(get_irn_mode(b_left))
&& values_in_mode(get_irn_mode(b_left), get_irn_mode(a_left))) {
ir_graph *irg = get_irn_irg(n);
dbg_info *dbgi = get_irn_dbg_info(n);
ir_node *block = get_nodes_block(n);
ir_mode *a_mode = get_irn_mode(a_left);
ir_mode *b_mode = get_irn_mode(b_left);
ir_node *xora = new_rd_Eor(dbgi, block, a_left, a_right, a_mode);
ir_node *xorb = new_rd_Eor(dbgi, block, b_left, b_right, b_mode);
ir_node *conv = new_rd_Conv(dbgi, block, xorb, a_mode);
ir_node *or = new_rd_Or(dbgi, block, xora, conv, a_mode);
ir_node *zero = create_zero_const(irg, a_mode);
return new_rd_Cmp(dbgi, block, or, zero, ir_relation_less_greater);
&& !mode_is_float(get_irn_mode(b_left))) {
if (values_in_mode(get_irn_mode(a_left), get_irn_mode(b_left))) {
ir_graph *irg = get_irn_irg(n);
dbg_info *dbgi = get_irn_dbg_info(n);
ir_node *block = get_nodes_block(n);
ir_mode *a_mode = get_irn_mode(a_left);
ir_mode *b_mode = get_irn_mode(b_left);
ir_node *xora = new_rd_Eor(dbgi, block, a_left, a_right, a_mode);
ir_node *xorb = new_rd_Eor(dbgi, block, b_left, b_right, b_mode);
ir_node *conv = new_rd_Conv(dbgi, block, xora, b_mode);
ir_node *or = new_rd_Or(dbgi, block, conv, xorb, b_mode);
ir_node *zero = create_zero_const(irg, b_mode);
return new_rd_Cmp(dbgi, block, or, zero, ir_relation_less_greater);
}
if (values_in_mode(get_irn_mode(b_left), get_irn_mode(a_left))) {
ir_graph *irg = get_irn_irg(n);
dbg_info *dbgi = get_irn_dbg_info(n);
ir_node *block = get_nodes_block(n);
ir_mode *a_mode = get_irn_mode(a_left);
ir_mode *b_mode = get_irn_mode(b_left);
ir_node *xora = new_rd_Eor(dbgi, block, a_left, a_right, a_mode);
ir_node *xorb = new_rd_Eor(dbgi, block, b_left, b_right, b_mode);
ir_node *conv = new_rd_Conv(dbgi, block, xorb, a_mode);
ir_node *or = new_rd_Or(dbgi, block, xora, conv, a_mode);
ir_node *zero = create_zero_const(irg, a_mode);
return new_rd_Cmp(dbgi, block, or, zero, ir_relation_less_greater);
}
}
}
......
Markdown is supported
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