Skip to content

[clang] Assertion failed in Vectorize #107501

Closed
@cardigan1008

Description

@cardigan1008

I compiled this code with -O2 flag and it crashed:

#include <stdint.h>
long a;
struct g {
  uint64_t h
};
int8_t i, j;
void b(int c, int, int d) {
  for (int e = 0; e < c; e++)
    a *= e * d;
}
long f() { return 1; }
int16_t k();
int16_t l(int16_t, uint8_t, struct g, int8_t, int64_t);
int32_t *m();
int64_t n();
int16_t o() {
  struct g p[8][1] = {};
  k(l(0, 0, p[4][1], 0, 0), p);
}
int16_t l(int16_t, uint8_t, struct g q, int8_t, int64_t) {
  int32_t *r;
  m(r, i && f() + (int)q.h + q.h);
}
int16_t safe_sub_func_int16_t_s_s(int16_t si1, int16_t si2)
{
  return (si1 - si2);
}
int32_t *m(int32_t *, int32_t s) {
  for (;; b(s + 3, 0, s + 1))
    if (s >= (j && &safe_sub_func_int16_t_s_s))
      n();
}

The crash is:

clang: /root/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7389: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), CostCtx, OrigLoop)) && " VPlan cost model and legacy cost model disagreed"' failed.

The details can be found here: https://godbolt.org/z/Gc9T5v5Yx

Metadata

Metadata

Assignees

No one assigned

    Labels

    crashPrefer [crash-on-valid] or [crash-on-invalid]vectorizers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions