public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/66777] New: faggressive-loop-optimizations behavior.
@ 2015-07-06 11:26 dongkyun.s at samsung dot com
  2015-07-06 12:11 ` [Bug c/66777] " rguenth at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: dongkyun.s at samsung dot com @ 2015-07-06 11:26 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 66777
           Summary: faggressive-loop-optimizations behavior.
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dongkyun.s at samsung dot com
  Target Milestone: ---

The following program seems to have optimized with -O2
(-faggressive-loop-optimizations).

#include <stdio.h>

int main(void)
{
        int a[5];
        int i;

        for (i = 0; a[i] && i < 5; i++)
                printf("%d\n", a[i]);

        return 0;
}

1) .s with -O2 option (-faggressive-loop-optimizations)
...
.L4
      r02     mo3w r0, #:lower16:.LC0
      movt    r0, #:upper16:.LC0
      bl      printf
      ldr     r1, [r4, #4]!
      cmp     r1, #0         // a[i]
      bne     .L4
...

2) .s without -On option (-fno-aggressive-loop-optimizations)
...
.L4
...
       ldr     r2, [fp, #-8]
       mvn     r3, #23
       mov     r2, r2, asl #2
       sub     r1, fp, #4
       add     r2, r2, r1
       add     r3, r2, r3
       ldr     r3, [r3, #0]
       cmp     r3, #0     // a[i]
       beq     .L3
       ldr     r3, [fp, #-8]
       cmp     r3, #4     // i < 5
       ble     .L4
.L3
...

< -faggressive-loop-optimizations >
This assumes that loop code does not invoke undefined behavior by for example
causing signed integer overflows or out-of-bound array accesses. The bounds for
the number of iterations of a loop are used to guide loop unrolling and peeling
and loop exit test optimizations. This option is enabled by default. 

The problem with 1) option (-faggressive-loop-optimizations) is that the
developer cannot recognize the program have bug which can cause NULL pointer
exception.

Is there some warning option releated to this optimization ?


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

* [Bug c/66777] faggressive-loop-optimizations behavior.
  2015-07-06 11:26 [Bug c/66777] New: faggressive-loop-optimizations behavior dongkyun.s at samsung dot com
@ 2015-07-06 12:11 ` rguenth at gcc dot gnu.org
  2015-07-07 22:19 ` ebotcazou at gcc dot gnu.org
  2015-07-07 23:31 ` dongkyun.s at samsung dot com
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-07-06 12:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
-Waggressive-loop-optimizations, but it doesn't warn for me in this case.  Of
course we warn about

t.c: In function ‘main’:
t.c:8:26: warning: ‘a[0]’ is used uninitialized in this function
[-Wuninitialized]
             for (i = 0; a[i] && i < 5; i++)
                          ^
>From gcc-bugs-return-491557-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Jul 06 12:12:41 2015
Return-Path: <gcc-bugs-return-491557-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 44814 invoked by alias); 6 Jul 2015 12:12:40 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 43539 invoked by uid 48); 6 Jul 2015 12:12:35 -0000
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/66759] [6 Regression] ICE in generic-match.c on 456.hmmer
Date: Mon, 06 Jul 2015 12:12:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: tree-optimization
X-Bugzilla-Version: 6.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: rguenth at gcc dot gnu.org
X-Bugzilla-Status: RESOLVED
X-Bugzilla-Resolution: FIXED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 6.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status resolution
Message-ID: <bug-66759-4-yLoy7o4oqi@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-66759-4@http.gcc.gnu.org/bugzilla/>
References: <bug-66759-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-07/txt/msg00447.txt.bz2
Content-length: 428

https://gcc.gnu.org/bugzilla/show_bug.cgi?idf759

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.


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

* [Bug c/66777] faggressive-loop-optimizations behavior.
  2015-07-06 11:26 [Bug c/66777] New: faggressive-loop-optimizations behavior dongkyun.s at samsung dot com
  2015-07-06 12:11 ` [Bug c/66777] " rguenth at gcc dot gnu.org
@ 2015-07-07 22:19 ` ebotcazou at gcc dot gnu.org
  2015-07-07 23:31 ` dongkyun.s at samsung dot com
  2 siblings, 0 replies; 4+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2015-07-07 22:19 UTC (permalink / raw)
  To: gcc-bugs

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

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-07-07
                 CC|                            |ebotcazou at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #2 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
> -Waggressive-loop-optimizations, but it doesn't warn for me in this case.

Note that it's enabled by default.  And it only warns for simple cases, in
particular not if you have a && in the exit condition.


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

* [Bug c/66777] faggressive-loop-optimizations behavior.
  2015-07-06 11:26 [Bug c/66777] New: faggressive-loop-optimizations behavior dongkyun.s at samsung dot com
  2015-07-06 12:11 ` [Bug c/66777] " rguenth at gcc dot gnu.org
  2015-07-07 22:19 ` ebotcazou at gcc dot gnu.org
@ 2015-07-07 23:31 ` dongkyun.s at samsung dot com
  2 siblings, 0 replies; 4+ messages in thread
From: dongkyun.s at samsung dot com @ 2015-07-07 23:31 UTC (permalink / raw)
  To: gcc-bugs

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

dongkyun.s at samsung dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #3 from dongkyun.s at samsung dot com ---
Verified and confirmed that this was caused by code bug (not by optimization
problem).


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

end of thread, other threads:[~2015-07-07 23:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-06 11:26 [Bug c/66777] New: faggressive-loop-optimizations behavior dongkyun.s at samsung dot com
2015-07-06 12:11 ` [Bug c/66777] " rguenth at gcc dot gnu.org
2015-07-07 22:19 ` ebotcazou at gcc dot gnu.org
2015-07-07 23:31 ` dongkyun.s at samsung dot com

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).