public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/21278] New: Move maximum out of a loop
@ 2005-04-29  8:17 tkoenig at gcc dot gnu dot org
  2005-04-30 17:52 ` [Bug tree-optimization/21278] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 4+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2005-04-29  8:17 UTC (permalink / raw)
  To: gcc-bugs

This could help in reducing the amount of work for bounds
checking.

$ cat mymax.c
#include <stdlib.h>
#include <stdio.h>

int main()
{
  char *p;
  int i,j,n;

  scanf("%d",&n);
  j = 0;
  for (i=0; i<n; i++)
    {
        if (j < i)
            j = i;
    }
    printf("%d\n",j);
    return 0;
}
$ gcc -g -funroll-all-loops -S -O3 -fdump-tree-optimized  mymax.c

still does the do loop:

<L13>:;
  j = 0;
  i = 0;

<L0>:;
  j = MAX_EXPR <j, i>;
  i = i + 1;
  if (i != n.10) goto <L0>; else goto <L4>;

when the loop could be optimized to

    if (n <= 0)
        j = 0;
    else
        j = n-1;

-- 
           Summary: Move maximum out of a loop
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tkoenig at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug tree-optimization/21278] Move maximum out of a loop
  2005-04-29  8:17 [Bug tree-optimization/21278] New: Move maximum out of a loop tkoenig at gcc dot gnu dot org
@ 2005-04-30 17:52 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-30 17:52 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-04-30 17:52 -------
Confirmed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2005-04-30 17:52:01
               date|                            |


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


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

* [Bug tree-optimization/21278] Move maximum out of a loop
       [not found] <bug-21278-4@http.gcc.gnu.org/bugzilla/>
  2021-08-19  1:53 ` pinskia at gcc dot gnu.org
@ 2023-06-09 15:41 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-09 15:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=21278

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2021-08-18 00:00:00         |2023-6-9

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Hmm, I think this is a job for final value replacement. I Know we handle &
already but this seems like something it could handle too.

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

* [Bug tree-optimization/21278] Move maximum out of a loop
       [not found] <bug-21278-4@http.gcc.gnu.org/bugzilla/>
@ 2021-08-19  1:53 ` pinskia at gcc dot gnu.org
  2023-06-09 15:41 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-19  1:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=21278

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2016-11-16 00:00:00         |2021-8-18

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
No compilers do this ...

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

end of thread, other threads:[~2023-06-09 15:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-29  8:17 [Bug tree-optimization/21278] New: Move maximum out of a loop tkoenig at gcc dot gnu dot org
2005-04-30 17:52 ` [Bug tree-optimization/21278] " pinskia at gcc dot gnu dot org
     [not found] <bug-21278-4@http.gcc.gnu.org/bugzilla/>
2021-08-19  1:53 ` pinskia at gcc dot gnu.org
2023-06-09 15:41 ` pinskia at gcc dot gnu.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).