Skip to content

64bit loop variable on 32bit may be optimized #133373

Open
@wzssyqa

Description

@wzssyqa

The Code like this

int x[128000];

void in(int k, int n) {
        for(unsigned long long i=0; i<128000; i++)
                x[i] = k;
}

If we build it for a 32bit system such as

./bin/clang --target=riscv32-linux-gnu -O3 -S n.c -emit-llvm

the 64bit one will be used, while in fact we can transform it to 32bit one, as it is less than 128000 always.

In fact gcc does this transform.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions