Commit ebb21655 authored by yb9976's avatar yb9976
Browse files

Fixed local optimization.

The transformation (a << c1) | c2 => (a | (c2 >> c1)) << c1
is only valid if the lower bits of c2 are clean.

This fixes opt/pr37102.c.
parent a1589472
......@@ -3108,6 +3108,14 @@ static ir_node *transform_node_bitop_shift(ir_node *n)
if (is_Shl(left)) {
tv_bitop = tarval_shr(tv2, tv1);
/* Check whether we have lost some bits during the right shift. */
if (is_Or(n) || is_Eor(n)) {
ir_tarval *tv_back_again = tarval_shl(tv_bitop, tv1);
if (tarval_cmp(tv_back_again, tv2) != ir_relation_equal)
return n;
}
} else if (is_Shr(left)) {
if (is_Or(n) || is_Eor(n)) {
/*
......
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