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]

[PATCH] PR middle-end/19055, (X | Y) ^ X -> Y & ~X


This patch implements a small bit optimization in fold which will help
targets with a instruction for andc (X & ~ Y) and should not hurt targets
which don't have it and that many registers. On X86 if X and Y are not used
afterwards, we actually save 2 bytes in code size. If they are used, there
is no loss.


OK? Bootstrapped and tested on powerpc-darwin with no regressions.

Thanks,
Andrew Pinski

ChangeLog:

* fold-const.c (fold_binary): Transform "(X | Y) ^ X" to "Y & ~ X".

testsuite/ChangeLog:

	* gcc.dg/tree-ssa/pr19055.c: New test.
	* gcc.dg/tree-ssa/pr19055-2.c: New test.


Attachment: t.diff.txt
Description: Text document


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