Skip to content

[PowerPC] Wrong code at O1 #172694

@XChy

Description

@XChy

Testcase:

void printf(char *, ...);
typedef long uint64_t;
int safe_lshift_func_int16_t_s_u_right, g_2322 = 2, g_3554;
static int g_939 = 2;
uint64_t g_1577;
short func_2___trans_tmp_4;
void func_2(signed char p_3, int p_4, uint64_t p_5)
{
    g_3554 = (p_3 && p_5) | p_4;
    for (;;)
    {
        uint64_t l_3564;
        __asm goto("" : : : : BS_LABEL_3);
        p_4 = p_3;
        if (p_5) break;
        func_2___trans_tmp_4 = p_3 < 0 ?: safe_lshift_func_int16_t_s_u_right;
    BS_LABEL_3:
    }
    g_1577 = p_5 && p_4;
}
int main()
{
    func_2(g_2322, 6, g_939);
    g_939 = 0;
    int crc = g_1577;
    printf("checksum = %X\n", crc);
}

Command:

> clang --target=powerpc64le-unknown-linux-musl --sysroot=/opt/ppc64/powerpc64le-unknown-linux-musl/sysroot --gcc-toolchain=/opt/ppc64 -O1 -static a.c
> qemu-ppc64le a.out
checksum = 0

> clang --target=powerpc64le-unknown-linux-musl --sysroot=/opt/ppc64/powerpc64le-unknown-linux-musl/sysroot --gcc-toolchain=/opt/ppc64 -O0 -static a.c
> qemu-ppc64le a.out
checksum = 1

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions