/**
* Eor is commutative and has neutral 0.
*/
-#define equivalent_node_Eor equivalent_node_neutral_zero
+static ir_node *equivalent_node_Eor(ir_node *n)
+{
+ ir_node *oldn = n;
+ ir_node *a;
+ ir_node *b;
+
+ n = equivalent_node_neutral_zero(n);
+ if (n != oldn) return n;
+
+ a = get_Eor_left(n);
+ b = get_Eor_right(n);
+
+ if (is_Eor(a)) {
+ ir_node *aa = get_Eor_left(a);
+ ir_node *ab = get_Eor_right(a);
+
+ if (aa == b) {
+ /* (a ^ b) ^ a -> b */
+ n = ab;
+ DBG_OPT_ALGSIM1(oldn, a, b, n, FS_OPT_EOR_A_B_A);
+ return n;
+ } else if (ab == b) {
+ /* (a ^ b) ^ b -> a */
+ n = aa;
+ DBG_OPT_ALGSIM1(oldn, a, b, n, FS_OPT_EOR_A_B_A);
+ return n;
+ }
+ }
+ if (is_Eor(b)) {
+ ir_node *ba = get_Eor_left(b);
+ ir_node *bb = get_Eor_right(b);
+
+ if (ba == a) {
+ /* a ^ (a ^ b) -> b */
+ n = bb;
+ DBG_OPT_ALGSIM1(oldn, a, b, n, FS_OPT_EOR_A_B_A);
+ return n;
+ } else if (bb == a) {
+ /* a ^ (b ^ a) -> b */
+ n = ba;
+ DBG_OPT_ALGSIM1(oldn, a, b, n, FS_OPT_EOR_A_B_A);
+ return n;
+ }
+ }
+
+ return n;
+}
/*
* Optimize a - 0 and (a - x) + x (for modes with wrap-around).
if (is_Const(b)) {
tarval *tv = get_Const_tarval(b);
+ int rem;
+ /*
+ * Floating point constant folding might be disabled here to
+ * prevent rounding.
+ * However, as we check for exact result, doing it is safe.
+ * Switch it on.
+ */
+ rem = tarval_enable_fp_ops(1);
tv = tarval_quo(get_mode_one(mode), tv);
+ (void)tarval_enable_fp_ops(rem);
/* Do the transformation if the result is either exact or we are not
using strict rules. */