llvm / llvm/llvm-project

SCEV verification fails with incorrect trip count after indvars

Open
#173,251 3 comments 0 reactions 0 assignees View on GitHub
llvm:SCEV loopoptim
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

SCEV verification fails on a testcase with dead loop after indvars.
https://godbolt.org/z/989vcjvdq

To reproduce run:

```
opt -passes='loop(indvars),verify' test.ll
```

Error message:

```
Trip Count for Loop at depth 1 containing: %dead_loop
Changed!
Old: 1
New: 0
Delta: 1
...
#5 0x00007768c90287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#6 0x000000000487074c llvm::ScalarEvolution::verify() const (/opt/compiler-explorer/clang-21.1.0/bin/opt+0x487074c)
...
```

Contributor guide

Open the contributing guide

Research direction

Start with the linked Godbolt testcase and reproduce the failure using opt with the loop(indvars) and verify passes. Read the ScalarEvolution verification path around the reported trip-count change for dead_loop; done means the testcase no longer reports an incorrect trip count or aborts verification.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.