Issue 240459
Summary [SLPVectorizer] assertion failure "ScalableVectorType is not supported." with SVE
Labels generated by fuzzer
Assignees
Reporter hazohelet
    Live Reproducer: https://godbolt.org/z/jGqsWosb7

Compiling the following C code for `aarch64` with `clang -O2 -march=armv9-a` crashes with assertion failure.

```c
_BitInt(3) g, p;
int h;
_BitInt(4) x;

static _BitInt(3) f(void) {
  int a = 0, b = 0;
  switch (h ? 0 : g) {
  case 0:
    b = p;
    a = 2;
  case 1:
    a = (p & g) | (p - a);
  }
 return b | a;
}

void m(unsigned n) {
  for (unsigned i = 0; i < (n & 7); i++) {
    x = f();
    h = 0;
  }
}
```

clang command:

```sh
clang --target=aarch64-linux-gnu -march=armv9-a -O2 -c repro.c
```

The compiler crashes with the following output:

```
clang: /home/runner/work/ccput/ccput/llvm/llvm/lib/Transforms/Vectorize/SLPVectorizer/SLPUtils.cpp:118: unsigned int llvm::slpvectorizer::getNumElements(llvm::Type*): Assertion `!isa<ScalableVectorType>(Ty) && "ScalableVectorType is not supported."' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and dumped files.
Stack dump:
0.	Program arguments: clang --target=aarch64-linux-gnu -march=armv9-a -O2 -c repro.c
1.	<eof> parser at end of file
2.	Optimizer
3.	Running pass "function<eager-inv>(...)" on module "repro.c"
4.	Running pass "slp-vectorizer" on function "m"
...
#11 llvm::slpvectorizer::getNumElements(llvm::Type*)
#12 llvm::slpvectorizer::BoUpSLP::getEntryCost(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::SmallPtrSetImpl<llvm::Value*>&)
#13 llvm::slpvectorizer::BoUpSLP::calculateTreeCostAndTrimNonProfitable(llvm::ArrayRef<llvm::Value*>, llvm::Instruction*)
#14 llvm::SLPVectorizerPass::tryToVectorizeList(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP&, bool, bool)
#15 bool tryToVectorizeSequence<llvm::Value>(llvm::VectorizeOptions const&, llvm::SmallVectorImpl<llvm::Value*>&, llvm::function_ref<bool (llvm::Value*, llvm::Value*)>, llvm::function_ref<bool (llvm::...
#16 llvm::SLPVectorizerPass::vectorizeOnceUsedSeeds(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&)
#17 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::Assum...
#18 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&)
```

Notes:

* The program also crashes at -O3, and with `-march=armv8-a+sve` or `-msve-vector-bits=256` . it compiles at -O1, -Os and -Oz, and without SVE
* compiles with `-fno-vectorize` or `-fno-slp-vectorize`

clang version:

```text
clang version 24.0.0git (https://github.com/llvm/llvm-project f5744e07d2dba7367ec68426fd6b6b07e2916b39)
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to