This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] fold-const.c: Fold (A & ~3) - (A & 3) into (A ^ 3) - 3.
- From: kenner at vlsi1 dot ultra dot nyu dot edu (Richard Kenner)
- To: kazu at cs dot umass dot edu
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 29 Sep 03 13:03:31 EDT
- Subject: Re: [patch] fold-const.c: Fold (A & ~3) - (A & 3) into (A ^ 3) - 3.
Here is a quick proof:
(A & ~3) - (A & 3) = (A & ~3) + ~(A & 3) + 1
This is not a "proof", but an *example*. However, I worked out an
informal-enough proof on paper to be convinced that it's actually correct.
+ /* Fold (A & ~3) - (A & 3) into (A ^ 3) - 3. */
This should say "B" not "3" and then say that it's a power of two minus 1.
+ && !TREE_SIDE_EFFECTS (TREE_OPERAND (arg0, 0))
+ && operand_equal_p (TREE_OPERAND (arg0, 0),
+ TREE_OPERAND (arg1, 0), 0)
operand_equal_p can't be true if there are side-effects, so that test
is redundant.
Otherwise OK.