[PATCH] Simplify x^y == z to x == y^z if y^z simplifies

Andrew Pinski pinskia@physics.uc.edu
Sun Dec 4 00:46:00 GMT 2005


While looking at optimizations which combine and LLVM does, I noticed that fold
does not simplify x^y == z to x == y^z when y^z simplifies.  This patch does the 
optimization.  I don't know many this actually actually helps but it can help in
the tree level where we would like to know if a variable is equal to a value or
not for cases like a^b == 0 or a^1 == 2.

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

Thanks,
Andrew Pinski

ChangeLog:
	* fold-const.c (fold_binary): Fold (a^b) == c to a == (b^c) if (b^c)
	simplifies or to b == (a^c) if (a^c) simplifies.

	* gcc.dg/tree-ssa/xor1.c: New test.
	* gcc.dg/tree-ssa/xor2.c: New test.
	* gcc.dg/tree-ssa/xor3.c: New test.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: PR23673.diff.txt
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20051204/696bc112/attachment.txt>


More information about the Gcc-patches mailing list