Skip to content

LLVM at -Oz can't remove a loop that can be removed at -O3 #112149

@dcci

Description

@dcci

https://godbolt.org/z/o7q1cjez1

void f() {
  int arr[5] = {1, 2, 3, 4, 5};
  for (int k = 0; k < 5; k++) {
    arr[k] *= 2;
  }
}

I haven't looked closely, but I suspect -O3 can simplify this loop as it unrolls and later finds out that the stores are dead. -Oz doesn't do that. IIRC at some point there was a loop re-roller that got removed which could potentially catch these cases.

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