This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]