public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/43529]  New: G++ doesn't optimize away empty loop when index is a double
@ 2010-03-25 23:42 evouga at gmail dot com
  2010-03-26 11:46 ` [Bug tree-optimization/43529] " rguenth at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: evouga at gmail dot com @ 2010-03-25 23:42 UTC (permalink / raw)
  To: gcc-bugs

Empty loops where the loop index is an integer are optimized away, but the
following loop is not (presumably because it is more difficult to prove that it
terminates in finite time?)

int main()
{
        for(double i=0; i<1e9; i+=1);
}

Command line: g++ -O3


-- 
           Summary: G++ doesn't optimize away empty loop when index is a
                    double
           Product: gcc
           Version: 4.4.1
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: evouga at gmail dot com


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


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

* [Bug tree-optimization/43529] G++ doesn't optimize away empty loop when index is a double
  2010-03-25 23:42 [Bug c++/43529] New: G++ doesn't optimize away empty loop when index is a double evouga at gmail dot com
@ 2010-03-26 11:46 ` rguenth at gcc dot gnu dot org
  2010-06-04 23:15 ` changpeng dot fang at amd dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-03-26 11:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2010-03-26 11:45 -------
Confirmed.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|minor                       |enhancement
             Status|UNCONFIRMED                 |NEW
          Component|c++                         |tree-optimization
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2010-03-26 11:45:52
               date|                            |


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


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

* [Bug tree-optimization/43529] G++ doesn't optimize away empty loop when index is a double
  2010-03-25 23:42 [Bug c++/43529] New: G++ doesn't optimize away empty loop when index is a double evouga at gmail dot com
  2010-03-26 11:46 ` [Bug tree-optimization/43529] " rguenth at gcc dot gnu dot org
@ 2010-06-04 23:15 ` changpeng dot fang at amd dot com
  2010-06-04 23:29 ` changpeng dot fang at amd dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: changpeng dot fang at amd dot com @ 2010-06-04 23:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from changpeng dot fang at amd dot com  2010-06-04 23:15 -------
Interesting! What's the difference between 17 and 18?
------------
int main()
{
  double i;
  for(i=0; i<18; i+=1); /* gcc -O3, empty loop not removed */
}
----------------
int main()
{
  double i;
  for(i=0; i<17; i+=1); /* gcc -O3, empty loop removed */
}


-- 

changpeng dot fang at amd dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |changpeng dot fang at amd
                   |                            |dot com


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


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

* [Bug tree-optimization/43529] G++ doesn't optimize away empty loop when index is a double
  2010-03-25 23:42 [Bug c++/43529] New: G++ doesn't optimize away empty loop when index is a double evouga at gmail dot com
  2010-03-26 11:46 ` [Bug tree-optimization/43529] " rguenth at gcc dot gnu dot org
  2010-06-04 23:15 ` changpeng dot fang at amd dot com
@ 2010-06-04 23:29 ` changpeng dot fang at amd dot com
  2010-06-05  0:05 ` pinskia at gcc dot gnu dot org
  2010-06-05 10:40 ` rguenth at gcc dot gnu dot org
  4 siblings, 0 replies; 7+ messages in thread
From: changpeng dot fang at amd dot com @ 2010-06-04 23:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from changpeng dot fang at amd dot com  2010-06-04 23:29 -------
(In reply to comment #2)
> Interesting! What's the difference between 17 and 18?
> ------------
> int main()
> {
>   double i;
>   for(i=0; i<18; i+=1); /* gcc -O3, empty loop not removed */
> }


The funny thing occurs in gcc 4, not gcc 6:

        .file   "empty.c"
        .text
        .p2align 4,,15
.globl main
        .type   main, @function
main:
.LFB0:
        .cfi_startproc
        xorl    %eax, %eax
        .p2align 4,,10
        .p2align 3
.L2:
        addl    $1, %eax
        cmpl    $18, %eax
        jne     .L2
        rep
        ret
        .cfi_endproc
.LFE0:
        .size   main, .-main
        .ident  "GCC: (Ubuntu 4.4.1-4ubuntu9) 4.4.1"
        .section        .note.GNU-stack,"",@progbits


-- 


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


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

* [Bug tree-optimization/43529] G++ doesn't optimize away empty loop when index is a double
  2010-03-25 23:42 [Bug c++/43529] New: G++ doesn't optimize away empty loop when index is a double evouga at gmail dot com
                   ` (2 preceding siblings ...)
  2010-06-04 23:29 ` changpeng dot fang at amd dot com
@ 2010-06-05  0:05 ` pinskia at gcc dot gnu dot org
  2010-06-05 10:40 ` rguenth at gcc dot gnu dot org
  4 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2010-06-05  0:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pinskia at gcc dot gnu dot org  2010-06-05 00:05 -------
>Interesting! What's the difference between 17 and 18?

Exact representation.


-- 


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


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

* [Bug tree-optimization/43529] G++ doesn't optimize away empty loop when index is a double
  2010-03-25 23:42 [Bug c++/43529] New: G++ doesn't optimize away empty loop when index is a double evouga at gmail dot com
                   ` (3 preceding siblings ...)
  2010-06-05  0:05 ` pinskia at gcc dot gnu dot org
@ 2010-06-05 10:40 ` rguenth at gcc dot gnu dot org
  4 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-06-05 10:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenth at gcc dot gnu dot org  2010-06-05 10:40 -------
(In reply to comment #4)
> >Interesting! What's the difference between 17 and 18?
> 
> Exact representation.

Complete unrolling.


-- 


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


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

* [Bug tree-optimization/43529] G++ doesn't optimize away empty loop when index is a double
       [not found] <bug-43529-4@http.gcc.gnu.org/bugzilla/>
@ 2023-08-08  1:38 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-08  1:38 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
the 19 case was fixed in GCC 4.5.0 uptill somewhere between 200 and 2000.
2000 and 1e9 is fixed in GCC 10 for C++ by ... and r10-7522-g75efe9cb1f8938 .

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

end of thread, other threads:[~2023-08-08  1:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-25 23:42 [Bug c++/43529] New: G++ doesn't optimize away empty loop when index is a double evouga at gmail dot com
2010-03-26 11:46 ` [Bug tree-optimization/43529] " rguenth at gcc dot gnu dot org
2010-06-04 23:15 ` changpeng dot fang at amd dot com
2010-06-04 23:29 ` changpeng dot fang at amd dot com
2010-06-05  0:05 ` pinskia at gcc dot gnu dot org
2010-06-05 10:40 ` rguenth at gcc dot gnu dot org
     [not found] <bug-43529-4@http.gcc.gnu.org/bugzilla/>
2023-08-08  1:38 ` 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).