public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/33512]  New: Simple bitwise simplification missed
@ 2007-09-20 22:32 pinskia at gcc dot gnu dot org
  2007-09-20 22:36 ` [Bug rtl-optimization/33512] " pinskia at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-09-20 22:32 UTC (permalink / raw)
  To: gcc-bugs

These two functions should produce the same code:
int f(int y, int x)
{
  return x & ((~x) | y);
}
int g(int y, int x)
{
  return y & x;
}

x & ((~x) | y) is the same as (x & ~x) | (x & y) using distribution and that
becomes (x & y) because (x & ~x) is always 0 and 0 | x is x.

This should be done at both the tree level and the RTL level.


-- 
           Summary: Simple bitwise simplification missed
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pinskia at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33512


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug rtl-optimization/33512] Simple bitwise simplification missed
  2007-09-20 22:32 [Bug rtl-optimization/33512] New: Simple bitwise simplification missed pinskia at gcc dot gnu dot org
@ 2007-09-20 22:36 ` pinskia at gcc dot gnu dot org
  2007-10-02 18:44 ` pinskia at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-09-20 22:36 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33512


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug rtl-optimization/33512] Simple bitwise simplification missed
  2007-09-20 22:32 [Bug rtl-optimization/33512] New: Simple bitwise simplification missed pinskia at gcc dot gnu dot org
  2007-09-20 22:36 ` [Bug rtl-optimization/33512] " pinskia at gcc dot gnu dot org
@ 2007-10-02 18:44 ` pinskia at gcc dot gnu dot org
  2008-02-23 18:00 ` pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-10-02 18:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2007-10-02 18:44 -------
Mine for RTL level:
Index: simplify-rtx.c
===================================================================
--- simplify-rtx.c      (revision 2035)
+++ simplify-rtx.c      (revision 2036)
@@ -1885,6 +1885,18 @@ simplify_binary_operation_1 (enum rtx_co
          return simplify_gen_unary (NOT, mode, tem, mode);
        }

+      /* (and X (ior (not X) Y) -> (and X Y) */
+      if (GET_CODE (op1) == IOR
+         && GET_CODE (XEXP (op1, 0)) == NOT
+         && op0 == XEXP (XEXP (op1, 0), 0))
+       return simplify_gen_binary (AND, mode, op0, XEXP (op1, 1));
+
+      /* (and (ior (not X) Y) X) -> (and X Y) */
+      if (GET_CODE (op0) == IOR
+         && GET_CODE (XEXP (op0, 0)) == NOT
+         && op1 == XEXP (XEXP (op0, 0), 0))
+       return simplify_gen_binary (AND, mode, op1, XEXP (op0, 1));
+
       tem = simplify_associative_operation (code, mode, op0, op1);
       if (tem)
        return tem;


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pinskia at gcc dot gnu dot
                   |dot org                     |org
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-10-02 18:44:09
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33512


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug rtl-optimization/33512] Simple bitwise simplification missed
  2007-09-20 22:32 [Bug rtl-optimization/33512] New: Simple bitwise simplification missed pinskia at gcc dot gnu dot org
  2007-09-20 22:36 ` [Bug rtl-optimization/33512] " pinskia at gcc dot gnu dot org
  2007-10-02 18:44 ` pinskia at gcc dot gnu dot org
@ 2008-02-23 18:00 ` pinskia at gcc dot gnu dot org
  2008-02-23 18:02 ` [Bug tree-optimization/33512] " pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-02-23 18:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2008-02-23 17:59 -------
Subject: Bug 33512

Author: pinskia
Date: Sat Feb 23 17:58:48 2008
New Revision: 132575

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=132575
Log:
2008-02-23  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR rtl-opt/33512
        * simplify-rtx.c (simplify_binary_operation_1): Add simplification
        of (and X (ior (not X) Y) and (and (ior (not X) Y) X).

2008-02-23  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR rtl-opt/33512
        * gcc.dg/and-1.c: New test.



Added:
    trunk/gcc/testsuite/gcc.dg/and-1.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/simplify-rtx.c
    trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33512


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug tree-optimization/33512] Simple bitwise simplification missed
  2007-09-20 22:32 [Bug rtl-optimization/33512] New: Simple bitwise simplification missed pinskia at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2008-02-23 18:00 ` pinskia at gcc dot gnu dot org
@ 2008-02-23 18:02 ` pinskia at gcc dot gnu dot org
  2008-04-04 21:20 ` janis at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-02-23 18:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2008-02-23 18:02 -------
The RTL level has been fixed.  The tree level needs fixing still but I am not
working on that.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
OtherBugsDependingO|33702                       |
              nThis|                            |
         AssignedTo|pinskia at gcc dot gnu dot  |unassigned at gcc dot gnu
                   |org                         |dot org
                URL|http://gcc.gnu.org/ml/gcc-  |
                   |patches/2008-               |
                   |02/msg01008.html            |
             Status|ASSIGNED                    |NEW
          Component|rtl-optimization            |tree-optimization
           Keywords|patch                       |TREE


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33512


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug tree-optimization/33512] Simple bitwise simplification missed
  2007-09-20 22:32 [Bug rtl-optimization/33512] New: Simple bitwise simplification missed pinskia at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2008-02-23 18:02 ` [Bug tree-optimization/33512] " pinskia at gcc dot gnu dot org
@ 2008-04-04 21:20 ` janis at gcc dot gnu dot org
  2008-04-04 21:22 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: janis at gcc dot gnu dot org @ 2008-04-04 21:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from janis at gcc dot gnu dot org  2008-04-04 21:19 -------
Test gcc.dg/and-1.c, added as a fix for this PR, fails on powerpc64-linux.  The
code generated for "-m64 -O2" is:

f:
        mr 0,3
        neg 3,3
        nand 3,3,0
        and 3,3,0
        blr


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33512


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug tree-optimization/33512] Simple bitwise simplification missed
  2007-09-20 22:32 [Bug rtl-optimization/33512] New: Simple bitwise simplification missed pinskia at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2008-04-04 21:20 ` janis at gcc dot gnu dot org
@ 2008-04-04 21:22 ` pinskia at gcc dot gnu dot org
  2008-07-15 14:54 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-04-04 21:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pinskia at gcc dot gnu dot org  2008-04-04 21:22 -------
(In reply to comment #4)
> Test gcc.dg/and-1.c, added as a fix for this PR, fails on powerpc64-linux.  The
> code generated for "-m64 -O2" is:

The issue is we see (and X (ior Y (not X) ) ), I will add this extra check
later this weekend.  In GCC 4.1.1, we saw what I had expected but for some
reasons GCC 4.3.0 has a different order of arguments.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33512


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug tree-optimization/33512] Simple bitwise simplification missed
  2007-09-20 22:32 [Bug rtl-optimization/33512] New: Simple bitwise simplification missed pinskia at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2008-04-04 21:22 ` pinskia at gcc dot gnu dot org
@ 2008-07-15 14:54 ` pinskia at gcc dot gnu dot org
  2008-11-23 18:46 ` pinskia at gcc dot gnu dot org
  2010-07-02 19:52 ` bergner at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-07-15 14:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pinskia at gcc dot gnu dot org  2008-07-15 14:53 -------
Mine still.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pinskia at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33512


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug tree-optimization/33512] Simple bitwise simplification missed
  2007-09-20 22:32 [Bug rtl-optimization/33512] New: Simple bitwise simplification missed pinskia at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2008-07-15 14:54 ` pinskia at gcc dot gnu dot org
@ 2008-11-23 18:46 ` pinskia at gcc dot gnu dot org
  2010-07-02 19:52 ` bergner at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-11-23 18:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pinskia at gcc dot gnu dot org  2008-11-23 18:45 -------
*** Bug 38218 has been marked as a duplicate of this bug. ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |howarth at nitro dot med dot
                   |                            |uc dot edu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33512


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug tree-optimization/33512] Simple bitwise simplification missed
  2007-09-20 22:32 [Bug rtl-optimization/33512] New: Simple bitwise simplification missed pinskia at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2008-11-23 18:46 ` pinskia at gcc dot gnu dot org
@ 2010-07-02 19:52 ` bergner at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: bergner at gcc dot gnu dot org @ 2010-07-02 19:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from bergner at gcc dot gnu dot org  2010-07-02 19:52 -------
So what asm do we expect that we should get form the and-1.c testcase?


-- 

bergner at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bergner at gcc dot gnu dot
                   |                            |org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33512


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-07-02 19:52 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-20 22:32 [Bug rtl-optimization/33512] New: Simple bitwise simplification missed pinskia at gcc dot gnu dot org
2007-09-20 22:36 ` [Bug rtl-optimization/33512] " pinskia at gcc dot gnu dot org
2007-10-02 18:44 ` pinskia at gcc dot gnu dot org
2008-02-23 18:00 ` pinskia at gcc dot gnu dot org
2008-02-23 18:02 ` [Bug tree-optimization/33512] " pinskia at gcc dot gnu dot org
2008-04-04 21:20 ` janis at gcc dot gnu dot org
2008-04-04 21:22 ` pinskia at gcc dot gnu dot org
2008-07-15 14:54 ` pinskia at gcc dot gnu dot org
2008-11-23 18:46 ` pinskia at gcc dot gnu dot org
2010-07-02 19:52 ` bergner at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).