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

--- Comment #2 from Theodoros Theodoridis <theodort at inf dot ethz.ch> ---
Not sure if it's useful but the following also started with the same commit: 


https://godbolt.org/z/Tqha4K976

Given the following code:

void foo(void);
static int d, e, h;
static int *f = &e, *q;
static int **g = &f;
static long j, p;
static short k;
void __assert_fail() __attribute__((__noreturn__));
static short(a)(short b, short c) {
    if (!(((b) >= -90) && ((b) <= 0))) {
        __builtin_unreachable();
    }
    return c == 0 || b == 1 && c == 1 ?: b % c;
}
static int **i();
static int l(int *m, long n) {
    j = 0 >= d;
    k = j - 34834;
    if (a(-n, k)) *g = m;
    if (f == 0 || f == &e)
        ;
    else
        __assert_fail();
    for (; h; ++h)
        ;
    return *m;
}
static int *o() {
    l(f, 90);
    g = i();
    if (f == 0 || f == &e)
        ;
    else
        foo();
    return &d;
}
static int **i() {
    a(p, h);
    return &q;
}
int main() { o(); }

gcc-trunk -O2 generates:

main:
        subq    $8, %rsp
        movq    f(%rip), %rax
        movq    g(%rip), %rdx
        movq    %rax, (%rdx)
        cmpq    $e, %rax
        je      .L7
        testq   %rax, %rax
        jne     .L2
.L7:
        movl    h(%rip), %edx
        testl   %edx, %edx
        je      .L5
        movl    $0, h(%rip)
.L5:
        movq    $q, g(%rip)
        cmpq    $e, %rax
        je      .L6
        call    foo
.L6:
        xorl    %eax, %eax
        addq    $8, %rsp
        ret
.L2:
        xorl    %eax, %eax
        call    __assert_fail

gcc-12.3.0 -O2 generates:

main:
        movq    f(%rip), %rax
        movq    g(%rip), %rdx
        movq    %rax, (%rdx)
        cmpq    $e, %rax
        je      .L6
        testq   %rax, %rax
        jne     .L2
.L6:
        movl    h(%rip), %edx
        testl   %edx, %edx
        je      .L5
        movl    $0, h(%rip)
.L5:
        movq    $q, g(%rip)
        xorl    %eax, %eax
        ret
.L2:
        pushq   %rax
        xorl    %eax, %eax
        call    __assert_fail

Reply via email to