[llvm] [VPlan] Enable vectorization of early-exit loops with unit-stride fault-only-first loads (PR #151300)

Shih-Po Hung via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 2 20:01:44 PDT 2025


arcbbb wrote:

> Hi, I wanted to try this patch but the new test is failing for a Release build:
> 
> ```
> ******************** TEST 'LLVM :: Transforms/LoopVectorize/RISCV/find.ll' FAILED ********************
> Exit Code: 2
> 
> Command Output (stdout):
> --
> # RUN: at line 2
> /home/rzinsly/build/llvm/bin/opt -passes=loop-vectorize -enable-early-exit-with-ffload -mtriple=riscv64 -mattr=+v -S /home/rzinsly/src/llvm-project/llvm/test/Transforms/LoopVectorize/RISCV/find.ll | /home/rzinsly/build/llvm/bin/FileCheck /home/rzinsly/src/llvm-project/llvm/test/Transforms/LoopVectorize/RISCV/find.ll
> # executed command: /home/rzinsly/build/llvm/bin/opt -passes=loop-vectorize -enable-early-exit-with-ffload -mtriple=riscv64 -mattr=+v -S /home/rzinsly/src/llvm-project/llvm/test/Transforms/LoopVectorize/RISCV/find.ll
> # .---command stderr------------
> # | PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
> # | Stack dump:
> # | 0.  Program arguments: /home/rzinsly/build/llvm/bin/opt -passes=loop-vectorize -enable-early-exit-with-ffload -mtriple=riscv64 -mattr=+v -S /home/rzinsly/src/llvm-project/llvm/test/Transforms/LoopVectorize/RISCV/find.ll
> # | 1.  Running pass "function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)" on module "/home/rzinsly/src/llvm-project/llvm/test/Transforms/LoopVectorize/RISCV/find.ll"
> # | 2.  Running pass "loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>" on function "find_with_liveout"
> # |  #0 0x00005a92b002fe62 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/rzinsly/build/llvm/bin/opt+0x2f67e62)
> # |  #1 0x00005a92b002cda2 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
> # |  #2 0x0000736eee245330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
> # |  #3 0x00005a92ae0d7df4 llvm::VPValue::getDefiningRecipe() (/home/rzinsly/build/llvm/bin/opt+0x100fdf4)
> # |  #4 0x00005a92ae1436c8 llvm::VPlanTransforms::adjustFFLoadEarlyExitForPoisonSafety(llvm::VPlan&) (/home/rzinsly/build/llvm/bin/opt+0x107b6c8)
> # |  #5 0x00005a92adf8422a llvm::LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(std::unique_ptr<llvm::VPlan, std::default_delete<llvm::VPlan>>, llvm::VFRange&, llvm::LoopVersioning*) (/home/rzinsly/build/llvm/bin/opt+0xebc22a)
> # |  #6 0x00005a92adf85c79 llvm::LoopVectorizationPlanner::buildVPlansWithVPRecipes(llvm::ElementCount, llvm::ElementCount) (/home/rzinsly/build/llvm/bin/opt+0xebdc79)
> # |  #7 0x00005a92adf861bd llvm::LoopVectorizationPlanner::plan(llvm::ElementCount, unsigned int) (/home/rzinsly/build/llvm/bin/opt+0xebe1bd)
> # |  #8 0x00005a92adf8bae4 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/home/rzinsly/build/llvm/bin/opt+0xec3ae4)
> ...
> ```
> 
> I’m building with: `-DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="RISCV" -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_PARALLEL_LINK_JOBS=1 -DLLVM_OPTIMIZED_TABLEGEN=ON `
> 
> It works with `-DCMAKE_BUILD_TYPE=Debug`.

Thanks for the report! I missed this when testing with a Release build +LLVM_ENABLE_ASSERTIONS=ON.
I’ve pushed a fix in the latest commit

https://github.com/llvm/llvm-project/pull/151300


More information about the llvm-commits mailing list