Take the following couple functions: int f(int a) { return (~a) != 0; } int f1(int a) { return a != (~0); } int f2(int a) { return (~a) != 1; } int f3(int a) { return a != (~1); } f and f1 should be the same. Likewise for f2 and f3.
This is done on the RTL level already but would be nice to get it at the TREE level so that it can fix if we have bools which is PR 18908. Mine working on a patch.
== and != should be handled the same. Change the summary to reflect the testcase in comment #0.
Patch posted.
Subject: Bug 24990 Author: pinskia Date: Fri Nov 25 04:54:59 2005 New Revision: 107487 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=107487 Log: 2005-11-25 Andrew Pinski <pinskia@physics.uc.edu> PR middle-end/24990 * fold-const.c (fold_binary): Fold (~a) == C to a == ~C for C being INTEGER_CST. Likewise for !=. 2005-11-24 Andrew Pinski <pinskia@physics.uc.edu> PR middle-end/24990 * tree-ssa/pr24990-1.c: New test. Added: trunk/gcc/testsuite/gcc.dg/tree-ssa/pr24990-1.c Modified: trunk/gcc/ChangeLog trunk/gcc/fold-const.c trunk/gcc/testsuite/ChangeLog
Fixed.