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: segher at d12relay02 dot megacenter dot de dot ibm dot com
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 30 Sep 03 08:01:22 EDT
- Subject: Re: [patch] fold-const.c: Fold (A & ~3) - (A & 3) into (A ^ 3) - 3.
This actually works for any B:
I didn't think so, but perhaps.
(A & ~B) - (A & B) = (A & ~B) + ~(A & B) + 1
--> = (A & ~B) + (~A & B) + ~B + 1
= (A & ~B) + (~A & B) - B
= (A ^ B) - B.
OK, that last step is true because you can prove the addition has no carries.
But I don't follow the marked step.