Skip to content

Loop vectorizer may create redundant preheader and scalar loop #111098

Open
@duk-37

Description

@duk-37

Compiler Explorer

#include <cstdint>

uint32_t foo(uint32_t *A, int n) {
  uint32_t sum = 0;
  for (int i = 0; i < n * 32; i++)
        sum += A[i];
  return sum;
}

Output IR is attached. I believe what's happening here is that the smax generated by SCEV expansion during IndVarSimplify interacts badly with SCEV checks in the loop vectorizer. I'm not quite sure though.

output.ll.txt

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