Skip to content

[clang] Assertion failed in Vectorize #107051

Closed
@cardigan1008

Description

@cardigan1008

I compiled this code with -Os and a crash appeared in assertion failure:

#include <stdint.h>
int32_t *c;
int8_t ****d;
uint64_t g;
int a();
long b(long, long h, long p3) {
  long e;
  int f = 0;
  if (h) {
    e = h;
    f = 1;
  }
  if (e > p3)
    f = 2;
  switch (f) {
  case 1:
    e++;
  case 2:
    e--;
  }
  if (e < h)
    e = h;
  return e;
}

uint8_t div_func_uint8_t_u_u(uint8_t ui1, uint8_t ui2)
{
  return (ui1 / ui2);
}

uint64_t j() {
  uint16_t k[8];
  int i;
  for (i = 0; *c + ****d + (int)g + i < 8; i++)
    k[b(0, g, 0)] = 6;
  *c = div_func_uint8_t_u_u(k[6], a());
}

The crash is:

clang: /root/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7369: 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.

Details can be found here: https://godbolt.org/z/T81adKPY5

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