Skip to content

[clang] Assertion failed in Vectorize #106248

@cardigan1008

Description

@cardigan1008

In #105722 , we resolved the assertion failure in vectorization. However, I met this crash again with the following case:

#include <stdint.h>
int a;
long b;
struct e {
  uint16_t f;
  uint64_t g;
  int32_t h
} static i = {65530};
void c(int d) {
  for (; a; a++)
    b *= d;
}
uint32_t j(struct e, uint16_t);
uint64_t k() { j(i, 0); }
uint32_t j(struct e, uint16_t) { c(i.f - 65528); }

I compiled it with -O2 flag and it crashed. But when I compiled with -O1/-O0, it worked.

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

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

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