On 04/20/2011 08:22 AM, Kai Tietz wrote: > + if (TREE_CODE (arg0) == BIT_AND_EXPR > + && TREE_CODE (arg1) == BIT_AND_EXPR) > + { > + tree a0, a1, l0, l1, n0, n1; > + > + a0 = fold_convert_loc (loc, type, TREE_OPERAND (arg1, 0)); > + a1 = fold_convert_loc (loc, type, TREE_OPERAND (arg1, 1)); > + > + l0 = fold_convert_loc (loc, type, TREE_OPERAND (arg0, 0)); > + l1 = fold_convert_loc (loc, type, TREE_OPERAND (arg0, 1)); > + > + n0 = fold_build1_loc (loc, BIT_NOT_EXPR, type, l0); > + n1 = fold_build1_loc (loc, BIT_NOT_EXPR, type, l1); > + > + if ((operand_equal_p (n0, a0, 0) > + && operand_equal_p (n1, a1, 0)) > + || (operand_equal_p (n0, a1, 0) > + && operand_equal_p (n1, a0, 0))) > + return fold_build2_loc (loc, TRUTH_XOR_EXPR, type, l0, n1);
First, you typoed BIT_XOR_EXPR in this first block. Second, I don't see how you're arbitrarily choosing L0 and N1 in the expansion. If you write the expression the other way around, (~x & y) | (x & ~y) don't you wind up with (~x ^ ~y) ? Or do the extra NOT expressions get folded away anyway? > + if (TREE_CODE (arg0) == TREE_CODE (arg1) > + && (TREE_CODE (arg1) == TRUTH_AND_EXPR > + || TREE_CODE (arg1) == TRUTH_ANDIF_EXPR)) I don't believe you want to apply this transformation with ANDIF. r~