[patch] fold-const.c: Fold (A & ~3) - (A & 3) into (A ^ 3) - 3.
Richard Kenner
kenner@vlsi1.ultra.nyu.edu
Mon Sep 29 17:10:00 GMT 2003
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.
More information about the Gcc-patches
mailing list