Question Details

No question body available.

Tags

clang llvm

Answers (1)

April 4, 2026 Score: 1 Rep: 1,121 Quality: Low Completeness: 80%

It's certainly possible by recompiling LLVM from source with added debug information. The relevant file is llvm/lib/Transforms/Vectorize/LoopVectorize.cpp, specifically the class LoopVectorizationCostModel.

I suspect the reason you're not given more information is that the cost model used by LLVM is too complex - so much that you need to understand it at source level for more info to be really useful. The available info seems to be more along the lines of "the model says it's not beneficial" vs "the model says it's beneficial but you explicitly disabled it". Making it more comprehensible is also an effort that someone would need to commit to. If you find generally useful info that doesn't have these caveats, you can contribute it to LLVM!

There are standard rules for what loops should be nicely vectorizable but if the cost model doesn't check them in a clean-cut way, it can't inform that a loop is falling short of some rule. Importantly, the class LoopVectorizationLegality first checks if a loop even can be vectorized and that has some extra debug info that can be useful; the cost model just decides if it's worth doing. So you're at least getting the info that your loop is vectorizable but there's probably too little gained by doing it.