[Bug tree-optimization/81388] New: Incorrect code generation with -O1 -fno-strict-overflow

terrelln at fb dot com gcc-bugzilla@gcc.gnu.org
Tue Jul 11 02:55:00 GMT 2017


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

            Bug ID: 81388
           Summary: Incorrect code generation with -O1
                    -fno-strict-overflow
           Product: gcc
           Version: 7.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: terrelln at fb dot com
  Target Milestone: ---

gcc 7.1 on x86 produces incorrect output for correct code. gcc 6.3 produced
correct assembly. See https://godbolt.org/g/mLyxGz or below for the code and
generated assembly.

code:
.----
// -O1 -fno-strict-overflow

void bar();
void foo(char *dst)
{
        char *const end = dst;
        do {
                bar();
                dst += 2;
        } while (dst < end);
}
`----

assembly:
.----
foo(char*):
        push    rbx
        movabs  rbx, -9223372036854775808
.L2:
        call    bar()
        sub     rbx, 1
        jne     .L2
        pop     rbx
        ret
`----


More information about the Gcc-bugs mailing list