public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/102666] New: Wrong loop optimization for unsigned types
@ 2021-10-09 17:03 davidsondfgl at gmail dot com
  2021-10-09 17:28 ` [Bug tree-optimization/102666] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: davidsondfgl at gmail dot com @ 2021-10-09 17:03 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102666
           Summary: Wrong loop optimization for unsigned types
           Product: gcc
           Version: 9.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: davidsondfgl at gmail dot com
  Target Milestone: ---

The code below produces incorrect result when any optimizations (-O1/-O2/-O3)
are enabled:

$ cat unsigned-bug.c
int main(void) {
    for (unsigned a = 0, b = 0; a < 6; a += 1, b += 2)
        if (b < a)
            return 1;
    return 0;
}

$ gcc -Wall -Wextra unsigned-bug.c; ./a.out; echo $?
0
$ gcc -Wall -Wextra unsigned-bug.c -O1; ./a.out; echo $?
1
$ gcc -Wall -Wextra unsigned-bug.c -O2; ./a.out; echo $?
1
$ gcc -Wall -Wextra unsigned-bug.c -O3; ./a.out; echo $?
1

This affects all releases as of 9.1, including the master branch (commit
2b30143).

A bisect between v9.1 and v8.3 indicates that this may have been introduced in
r266171, as I can revert this commit (a81e2c6) in all releases up to v11.2 and
get the expected behavior.

It is also worthwhile to note that this only occurs for unsigned types.

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

* [Bug tree-optimization/102666] Wrong loop optimization for unsigned types
  2021-10-09 17:03 [Bug tree-optimization/102666] New: Wrong loop optimization for unsigned types davidsondfgl at gmail dot com
@ 2021-10-09 17:28 ` pinskia at gcc dot gnu.org
  2021-10-09 21:58 ` [Bug tree-optimization/102666] Wrong loop optimization for unsigned types after r9-4145 pinskia at gcc dot gnu.org
  2021-10-09 22:06 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-10-09 17:28 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 100740 (or PR 101508 or PR 101972).

*** This bug has been marked as a duplicate of bug 100740 ***

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

* [Bug tree-optimization/102666] Wrong loop optimization for unsigned types after r9-4145
  2021-10-09 17:03 [Bug tree-optimization/102666] New: Wrong loop optimization for unsigned types davidsondfgl at gmail dot com
  2021-10-09 17:28 ` [Bug tree-optimization/102666] " pinskia at gcc dot gnu.org
@ 2021-10-09 21:58 ` pinskia at gcc dot gnu.org
  2021-10-09 22:06 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-10-09 21:58 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ibuclaw at gcc dot gnu.org

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 102673 has been marked as a duplicate of this bug. ***

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

* [Bug tree-optimization/102666] Wrong loop optimization for unsigned types after r9-4145
  2021-10-09 17:03 [Bug tree-optimization/102666] New: Wrong loop optimization for unsigned types davidsondfgl at gmail dot com
  2021-10-09 17:28 ` [Bug tree-optimization/102666] " pinskia at gcc dot gnu.org
  2021-10-09 21:58 ` [Bug tree-optimization/102666] Wrong loop optimization for unsigned types after r9-4145 pinskia at gcc dot gnu.org
@ 2021-10-09 22:06 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-10-09 22:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 102673 has been marked as a duplicate of this bug. ***

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

end of thread, other threads:[~2021-10-09 22:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-09 17:03 [Bug tree-optimization/102666] New: Wrong loop optimization for unsigned types davidsondfgl at gmail dot com
2021-10-09 17:28 ` [Bug tree-optimization/102666] " pinskia at gcc dot gnu.org
2021-10-09 21:58 ` [Bug tree-optimization/102666] Wrong loop optimization for unsigned types after r9-4145 pinskia at gcc dot gnu.org
2021-10-09 22:06 ` 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).