[llvm] [SLP][NFC]Extract values state/operands analysis into separate class (PR #138724)

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Sun May 11 08:31:52 PDT 2025


alexey-bataev wrote:

> I've just reverted this commit in [6a2a8eb](https://github.com/llvm/llvm-project/commit/6a2a8ebe27c1941f5b952313239fc6d155f58e9d) (EDIT: and here's the build going green again after this revert https://lab.llvm.org/buildbot/#/builders/132/builds/1052)
> 
> It's causing the RVV CI to fail with a crash compiling oggenc.c from llvm-test-suite. I've reduced the C input to come up with this test case:
> 
> reduced oggenc.c:
> 
> ```c
> float *mdct_forward_x;
> int mdct_forward_j;
> void mdct_butterfly_16(float *x) {
>   float r0 = x[6] + 2, r1 = x[6] - x[2], r2 = 4 + x[0], r3 = x[4] - x[0];
>   x[4] = r0 - r2;
>   r0 = 5 - x[1];
>   r2 = 7 - x[3];
>   x[0] = r0;
>   x[2] = r1 - r0;
>   x[3] = r2 + r3;
>   x[5] = r1 - r0;
> }
> void mdct_butterfly_32(float *x) { mdct_butterfly_16(x + 6); }
> void mdct_forward() {
>   for (;;)
>     mdct_butterfly_32(mdct_forward_x + mdct_forward_j);
> }
> ```
> 
> Then to reproduce the crash:
> 
> ```
> ~/llvm-project/build/release/bin/clang --target=riscv64-linux-gnu -march=rv64gcv -O3 -c oggenc.c -fno-strict-aliasing
> clang: ../../llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:19512: auto llvm::slpvectorizer::BoUpSLP::BlockScheduling::tryScheduleBundle(ArrayRef<Value *>, BoUpSLP *, const InstructionsState &)::(anonymous class)::operator()(bool, ScheduleBundle &) const: Assertion `Picked->isReady() && "must be ready to schedule"' failed.
> PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
> Stack dump:
> 0.	Program arguments: /home/asb/llvm-project/build/release/bin/clang --target=riscv64-linux-gnu -march=rv64gcv -O3 -c oggenc.c -fno-strict-aliasing
> 1.	<eof> parser at end of file
> 2.	Optimizer
> 3.	Running pass "function<eager-inv>(float2int,lower-constant-intrinsics,chr,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-verify-fixpoint>,loop-unroll<O3>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)" on module "oggenc.c"
> 4.	Running pass "slp-vectorizer" on function "mdct_forward"
>  #0 0x000060a794223306 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/asb/llvm-project/build/release/bin/clang+0x8789306)
>  #1 0x000060a794220c1e llvm::sys::RunSignalHandlers() (/home/asb/llvm-project/build/release/bin/clang+0x8786c1e)
>  #2 0x000060a79418239d CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
>  #3 0x00007c6e1424c1d0 (/usr/lib/libc.so.6+0x3d1d0)
>  #4 0x00007c6e142a5334 (/usr/lib/libc.so.6+0x96334)
>  #5 0x00007c6e1424c120 raise (/usr/lib/libc.so.6+0x3d120)
>  #6 0x00007c6e142334c3 abort (/usr/lib/libc.so.6+0x244c3)
>  #7 0x00007c6e142333df (/usr/lib/libc.so.6+0x243df)
>  #8 0x00007c6e14244177 (/usr/lib/libc.so.6+0x35177)
>  #9 0x000060a795db0d31 llvm::slpvectorizer::BoUpSLP::BlockScheduling::tryScheduleBundle(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP*, (anonymous namespace)::InstructionsState const&)::$_0::operator()(bool, llvm::slpvectorizer::BoUpSLP::ScheduleBundle&) const SLPVectorizer.cpp:0:0
> #10 0x000060a795d1b82a llvm::slpvectorizer::BoUpSLP::buildTreeRec(llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&, unsigned int) (/home/asb/llvm-project/build/release/bin/clang+0xa28182a)
> #11 0x000060a795d1ad91 llvm::slpvectorizer::BoUpSLP::buildTreeRec(llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&, unsigned int) (/home/asb/llvm-project/build/release/bin/clang+0xa280d91)
> ........
> ........
> ```
> 
> Looking at the diff of a log with `-mllvm -debug -mllvm -print-after-all` I see it starts to diverge in the ordering of some operands listed in printouts (i.e. under `Operand 0:`).

Thanks, fixed


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


More information about the llvm-commits mailing list