https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90323

--- Comment #19 from Segher Boessenkool <segher at gcc dot gnu.org> ---
(In reply to luoxhu from comment #17)
> And what do you mean"This is not canonical form on RTL, and it's not a
> useful form either" in c#7, please? Not understanding the point...

On Gimple it is canonical to convert (a&c)|(b&~c) to ((a^b)&c)^b), because
all Gimple cares about is number of operations (and it counts unary operations
as well, so this is three instead of four ops).

For RTL we do not have such a simple-minded rule.

> --- a/gcc/simplify-rtx.c
> +++ b/gcc/simplify-rtx.c
> @@ -3405,7 +3405,6 @@ simplify_context::simplify_binary_operation_1
> (rtx_code code,
>          machines, and also has shorter instruction path length.  */
>        if (GET_CODE (op0) == AND
>           && GET_CODE (XEXP (op0, 0)) == XOR
> -         && CONST_INT_P (XEXP (op0, 1))
>           && rtx_equal_p (XEXP (XEXP (op0, 0), 0), trueop1))
>         {
>           rtx a = trueop1;
> @@ -3419,7 +3418,6 @@ simplify_context::simplify_binary_operation_1
> (rtx_code code,
>        /* Similarly, (xor (and (xor A B) C) B) as (ior (and A C) (and B ~C))
> */
>        else if (GET_CODE (op0) == AND
>           && GET_CODE (XEXP (op0, 0)) == XOR
> -         && CONST_INT_P (XEXP (op0, 1))
>           && rtx_equal_p (XEXP (XEXP (op0, 0), 1), trueop1))
>         {
>           rtx a = XEXP (XEXP (op0, 0), 0);

It needs *some* test on it.  It certainly cannot have side effects for
example.  CONST_INT_P || REG_P should catch all useful cases?

Reply via email to