Commit 78ad9c61 authored by Matthias Braun's avatar Matthias Braun
Browse files

iropt: add rule a+(-a)==0

The simple x+(-x) case worked already because it was converted to a x-x,
but the more complicated case (x-y) + (y-x) did not work. While
certainly the reassoc could perform better here, adding this rule
as a localopt doesn't hurt.
parent f8709188
......@@ -304,6 +304,12 @@ static ir_tarval *computed_value_Add(const ir_node *n)
/* x+~x => -1 */
if (complement_values(a, b))
return get_mode_all_one(get_irn_mode(n));
/* x + -x => 0 */
if (ir_is_negated_value(a, b)) {
ir_mode *mode = get_irn_mode(n);
if (get_mode_arithmetic(mode) == irma_twos_complement)
return get_mode_null(mode);
}
return tarval_unknown;
}
......
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