Skip to content

[clang] Crash with assertion failed in Vectorize #107015

@cardigan1008

Description

@cardigan1008

The compiler crashed with -O2 in this code:

#include<stdint.h>
static uint8_t b[][1] = {127};
long a(int c, int e) {
  long d;
  for (; c <= e; c++)
    if (c % 2 == 0)
      ;
    else
      d *= c;
  return d;
}
int64_t f();
int16_t g() {
  int32_t h = 1653000360;
  f(a(h - 1653000360, b[0][0] - 126));
  uint8_t *i[] = {b, b};
}

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.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.

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

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