Bug 24989 - boolvar != 1 is not converted to !boolvar
Summary: boolvar != 1 is not converted to !boolvar
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.1.0
: P3 enhancement
Target Milestone: 4.2.0
Assignee: Andrew Pinski
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: missed-optimization, patch, xfail
Depends on:
Blocks: 19987 18908
  Show dependency treegraph
 
Reported: 2005-11-22 19:40 UTC by Andrew Pinski
Modified: 2005-11-25 05:05 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-11-22 19:41:49


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Pinski 2005-11-22 19:40:49 UTC
The following two function should be the same:
_Bool f(_Bool a)
{
  return a!=1;
}
_Bool f1(_Bool a)
{
  _Bool b = !a;
  return b;
}

Right now f1 is the most optimal.
Comment 1 Andrew Pinski 2005-11-22 19:41:49 UTC
I am working on a patch to fix this.  This should also fix f3 in PR 18908.
Comment 2 Andrew Pinski 2005-11-23 04:04:13 UTC
This actually has a xfail testcase associated with it (I think I forgot to file the bug when I added the testcase).
Comment 3 Andrew Pinski 2005-11-24 06:14:26 UTC
XPASS: gcc.dg/tree-ssa/bool-7.c scan-tree-dump-times != 1 0
Comment 4 Andrew Pinski 2005-11-24 21:19:35 UTC
Patch posted:
http://gcc.gnu.org/ml/gcc-patches/2005-11/msg01780.html
Comment 5 Andrew Pinski 2005-11-25 05:05:30 UTC
Subject: Bug 24989

Author: pinskia
Date: Fri Nov 25 05:05:26 2005
New Revision: 107488

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=107488
Log:
2005-11-25  Andrew Pinski  <pinskia@physics.uc.edu>

        PR middle-end/24989
        * fold-const.c (fold_build): Convert bool_var != 1 and
        bool_var == 0 to !bool_var.

2005-11-24  Andrew Pinski  <pinskia@physics.uc.edu>

        PR middle-end/24989
        * gcc.dg/tree-ssa/bool-10.c: New test.
        * gcc.dg/tree-ssa/bool-11.c: New test.
        * gcc.dg/tree-ssa/bool-7.c: Un-xfail.


Added:
    trunk/gcc/testsuite/gcc.dg/tree-ssa/bool-10.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/bool-11.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/fold-const.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/tree-ssa/bool-7.c

Comment 6 Andrew Pinski 2005-11-25 05:05:38 UTC
Fixed.