public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/24427]  New: missing optimization opportunity with binary operators
@ 2005-10-18 13:07 dvilleneuve at kronos dot com
  2005-10-18 13:42 ` [Bug middle-end/24427] " pinskia at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: dvilleneuve at kronos dot com @ 2005-10-18 13:07 UTC (permalink / raw)
  To: gcc-bugs

In the code below, the test is always true and could be found as such by using
distributivity on binary operators to factor out constant values.  This is not
currently done, by looking at the assembly code produced.

<code>
extern int f(unsigned);

int f(unsigned u)
{
  if( (u|4) & 6 ) /* could be tested as (u&6) || (4&6), always true */
    return 5;
  else
    return 10;
}
</code>


-- 
           Summary: missing optimization opportunity with binary operators
           Product: gcc
           Version: 4.0.1
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P4
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dvilleneuve at kronos dot com
GCC target triplet: i386-redhat-linux


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


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

* [Bug middle-end/24427] missing optimization opportunity with binary operators
  2005-10-18 13:07 [Bug tree-optimization/24427] New: missing optimization opportunity with binary operators dvilleneuve at kronos dot com
@ 2005-10-18 13:42 ` pinskia at gcc dot gnu dot org
  2005-10-19 10:25 ` rguenth at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-10-18 13:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2005-10-18 13:42 -------
Confirmed.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
OtherBugsDependingO|                            |19987
              nThis|                            |
             Status|UNCONFIRMED                 |NEW
          Component|tree-optimization           |middle-end
     Ever Confirmed|0                           |1
           Keywords|                            |missed-optimization
   Last reconfirmed|0000-00-00 00:00:00         |2005-10-18 13:42:23
               date|                            |


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


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

* [Bug middle-end/24427] missing optimization opportunity with binary operators
  2005-10-18 13:07 [Bug tree-optimization/24427] New: missing optimization opportunity with binary operators dvilleneuve at kronos dot com
  2005-10-18 13:42 ` [Bug middle-end/24427] " pinskia at gcc dot gnu dot org
@ 2005-10-19 10:25 ` rguenth at gcc dot gnu dot org
  2006-02-13 18:33 ` sayle at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-10-19 10:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rguenth at gcc dot gnu dot org  2005-10-19 10:25 -------
fold-const.c:distribute_bit_expr should be extended to handle this case.


-- 

rguenth at gcc dot gnu dot org changed:

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


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


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

* [Bug middle-end/24427] missing optimization opportunity with binary operators
  2005-10-18 13:07 [Bug tree-optimization/24427] New: missing optimization opportunity with binary operators dvilleneuve at kronos dot com
  2005-10-18 13:42 ` [Bug middle-end/24427] " pinskia at gcc dot gnu dot org
  2005-10-19 10:25 ` rguenth at gcc dot gnu dot org
@ 2006-02-13 18:33 ` sayle at gcc dot gnu dot org
  2006-02-14  3:07 ` roger at eyesopen dot com
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: sayle at gcc dot gnu dot org @ 2006-02-13 18:33 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from sayle at gcc dot gnu dot org  2006-02-13 18:33 -------
Subject: Bug 24427

Author: sayle
Date: Mon Feb 13 18:33:32 2006
New Revision: 110918

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=110918
Log:

        PR middle-end/24427
        * fold-const.c (fold_binary) <BIT_IOR_EXPR>: Transform (X&C1)|C2
        into (X,C2) if C1 is a subset of the bits of C2.  Transform
        (X&C1)|C2 into X|C2 if C1|C2 == ~0.  Canonicalize (X&C1)|C2 as
        (X&(C1&~C2))|C2.
        <BIT_AND_EXPR>: Canonicalize (X|C1)&C2 as (X&C2)|(C1&C2).

        * gcc.dg/tree-ssa/andor-1.c: New test case.


Added:
    trunk/gcc/testsuite/gcc.dg/tree-ssa/andor-1.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/fold-const.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug middle-end/24427] missing optimization opportunity with binary operators
  2005-10-18 13:07 [Bug tree-optimization/24427] New: missing optimization opportunity with binary operators dvilleneuve at kronos dot com
                   ` (2 preceding siblings ...)
  2006-02-13 18:33 ` sayle at gcc dot gnu dot org
@ 2006-02-14  3:07 ` roger at eyesopen dot com
  2006-06-26 19:23 ` ramana dot radhakrishnan at codito dot com
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: roger at eyesopen dot com @ 2006-02-14  3:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from roger at eyesopen dot com  2006-02-14 03:07 -------
This has now been fixed on mainline.


-- 

roger at eyesopen dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.2.0


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


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

* [Bug middle-end/24427] missing optimization opportunity with binary operators
  2005-10-18 13:07 [Bug tree-optimization/24427] New: missing optimization opportunity with binary operators dvilleneuve at kronos dot com
                   ` (3 preceding siblings ...)
  2006-02-14  3:07 ` roger at eyesopen dot com
@ 2006-06-26 19:23 ` ramana dot radhakrishnan at codito dot com
  2006-09-13  4:02 ` bangerth at dealii dot org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: ramana dot radhakrishnan at codito dot com @ 2006-06-26 19:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from ramana dot radhakrishnan at codito dot com  2006-06-26 19:13 -------
This should be reopened. A related testcase shows a regression from 3.4.6 to
4.1.1 for m68k-elf shows a regression . combine used to take care of this in
3.4.6   . A backport of the patch is ready with me. If its allowed, I'll put it
up . 

This is the test case . 

#include <stdio.h>
int i;
int main (void)
{

          if ( ((i & ~1) | 1) != ( i | 1))
                      printf ("abc");
}

3.4.6 generated 

       .file   "fail.c"
        .text
        .align  2
        .globl  foo
        .type   foo, @function
foo:
        link.w %a6,#0
        unlk %a6
        rts
        .size   foo, .-foo
        .comm   i,4,2
        .ident  "GCC: (GNU) 3.4.6"



4.1.2 pre-release generates      

.file   "fail.c"
        .section        .rodata.str1.1,"aMS",@progbits,1
.LC0:
        .string "abc"
        .text
        .align  2
        .globl  main
        .type   main, @function
main:
        link.w %fp,#0
        move.l %d2,-(%sp)
        move.l i,%d1
        moveq #-2,%d0
        and.l %d1,%d0
        moveq #1,%d2
        or.l %d2,%d0
        or.l %d2,%d1
        cmp.l %d0,%d1
        jbeq .L5
        pea .LC0
        jbsr printf
        addq.l #4,%sp
.L5:
        move.l -4(%fp),%d2
        unlk %fp
        rts
        .size   main, .-main
        .comm   i,4,2
        .ident  "GCC: (GNU) 4.1.2 20060623 (prerelease)"


-- 

ramana dot radhakrishnan at codito dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ramana dot radhakrishnan at
                   |                            |codito dot com


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


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

* [Bug middle-end/24427] missing optimization opportunity with binary operators
  2005-10-18 13:07 [Bug tree-optimization/24427] New: missing optimization opportunity with binary operators dvilleneuve at kronos dot com
                   ` (4 preceding siblings ...)
  2006-06-26 19:23 ` ramana dot radhakrishnan at codito dot com
@ 2006-09-13  4:02 ` bangerth at dealii dot org
  2006-09-13  4:08 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: bangerth at dealii dot org @ 2006-09-13  4:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from bangerth at dealii dot org  2006-09-13 04:02 -------
Isn't this a duplicate of PR 28173 now?


-- 

bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bangerth at dealii dot org


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


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

* [Bug middle-end/24427] missing optimization opportunity with binary operators
  2005-10-18 13:07 [Bug tree-optimization/24427] New: missing optimization opportunity with binary operators dvilleneuve at kronos dot com
                   ` (5 preceding siblings ...)
  2006-09-13  4:02 ` bangerth at dealii dot org
@ 2006-09-13  4:08 ` pinskia at gcc dot gnu dot org
  2007-02-18 17:10 ` sayle at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-09-13  4:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pinskia at gcc dot gnu dot org  2006-09-13 04:08 -------
(In reply to comment #6)
> Isn't this a duplicate of PR 28173 now?
Besides PR 28173 is a regression.


-- 


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


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

* [Bug middle-end/24427] missing optimization opportunity with binary operators
  2005-10-18 13:07 [Bug tree-optimization/24427] New: missing optimization opportunity with binary operators dvilleneuve at kronos dot com
                   ` (6 preceding siblings ...)
  2006-09-13  4:08 ` pinskia at gcc dot gnu dot org
@ 2007-02-18 17:10 ` sayle at gcc dot gnu dot org
  2007-02-18 17:58 ` ebotcazou at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: sayle at gcc dot gnu dot org @ 2007-02-18 17:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from sayle at gcc dot gnu dot org  2007-02-18 17:10 -------
Subject: Bug 24427

Author: sayle
Date: Sun Feb 18 17:10:19 2007
New Revision: 122100

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=122100
Log:

        Backport from mainline.
        PR middle-end/24427
        PR rtl-optimization/28173
        * fold-const.c (fold_binary) <BIT_IOR_EXPR>: Transform (X&C1)|C2
        into (X,C2) if C1 is a subset of the bits of C2.  Transform
        (X&C1)|C2 into X|C2 if C1|C2 == ~0.  Canonicalize (X&C1)|C2 as
        (X&(C1&~C2))|C2.
        <BIT_AND_EXPR>: Canonicalize (X|C1)&C2 as (X&C2)|(C1&C2).

        * gcc.dg/tree-ssa/andor-1.c: New test case.


Added:
    branches/gcc-4_1-branch/gcc/testsuite/gcc.dg/tree-ssa/andor-1.c
Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/fold-const.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug middle-end/24427] missing optimization opportunity with binary operators
  2005-10-18 13:07 [Bug tree-optimization/24427] New: missing optimization opportunity with binary operators dvilleneuve at kronos dot com
                   ` (7 preceding siblings ...)
  2007-02-18 17:10 ` sayle at gcc dot gnu dot org
@ 2007-02-18 17:58 ` ebotcazou at gcc dot gnu dot org
  2007-02-18 18:10 ` roger at eyesopen dot com
  2007-02-18 18:50 ` ebotcazou at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2007-02-18 17:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from ebotcazou at gcc dot gnu dot org  2007-02-18 17:58 -------
Roger, I'm a little puzzled by your last move: is it really necessary to
backport a patch for a missed optimization, after a delay of 1 full year,
to a branch which is supposed to be in stabilization mode now?  IMHO it's
too late.


-- 

ebotcazou at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sayle at gcc dot gnu dot
                   |                            |org, ebotcazou at gcc dot
                   |                            |gnu dot org


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


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

* [Bug middle-end/24427] missing optimization opportunity with binary operators
  2005-10-18 13:07 [Bug tree-optimization/24427] New: missing optimization opportunity with binary operators dvilleneuve at kronos dot com
                   ` (8 preceding siblings ...)
  2007-02-18 17:58 ` ebotcazou at gcc dot gnu dot org
@ 2007-02-18 18:10 ` roger at eyesopen dot com
  2007-02-18 18:50 ` ebotcazou at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: roger at eyesopen dot com @ 2007-02-18 18:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from roger at eyesopen dot com  2007-02-18 18:10 -------
Hi Eric,

It's not PR24427 that's the motivation for this backport, but PR 28173.
In fact, it was *your* request in comment #2 of PR28173 to backport this!
I'm a little disappointed you'd even question my decision/authority to
backport a regression fix. :-)

Roger
--


-- 


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


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

* [Bug middle-end/24427] missing optimization opportunity with binary operators
  2005-10-18 13:07 [Bug tree-optimization/24427] New: missing optimization opportunity with binary operators dvilleneuve at kronos dot com
                   ` (9 preceding siblings ...)
  2007-02-18 18:10 ` roger at eyesopen dot com
@ 2007-02-18 18:50 ` ebotcazou at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2007-02-18 18:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from ebotcazou at gcc dot gnu dot org  2007-02-18 18:50 -------
> It's not PR24427 that's the motivation for this backport, but PR 28173.
> In fact, it was *your* request in comment #2 of PR28173 to backport this!

Well, I only requested that you comment on the proposed backport.  And this
was on 2006-09-13, so 5 months ago!

> I'm a little disappointed you'd even question my decision/authority to
> backport a regression fix. :-)

I'm basically paid for that. :-)


-- 


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


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

end of thread, other threads:[~2007-02-18 18:50 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-18 13:07 [Bug tree-optimization/24427] New: missing optimization opportunity with binary operators dvilleneuve at kronos dot com
2005-10-18 13:42 ` [Bug middle-end/24427] " pinskia at gcc dot gnu dot org
2005-10-19 10:25 ` rguenth at gcc dot gnu dot org
2006-02-13 18:33 ` sayle at gcc dot gnu dot org
2006-02-14  3:07 ` roger at eyesopen dot com
2006-06-26 19:23 ` ramana dot radhakrishnan at codito dot com
2006-09-13  4:02 ` bangerth at dealii dot org
2006-09-13  4:08 ` pinskia at gcc dot gnu dot org
2007-02-18 17:10 ` sayle at gcc dot gnu dot org
2007-02-18 17:58 ` ebotcazou at gcc dot gnu dot org
2007-02-18 18:10 ` roger at eyesopen dot com
2007-02-18 18:50 ` ebotcazou 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).