[llvm] [VectorCombine] Support simplification to scalar store for multiple insertelt (PR #132820)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Fri May 29 22:36:56 PDT 2026


dtcxzyw wrote:

The following correctness issue was found by [llvm-hackme](https://github.com/dtcxzyw/llvm-hackme).

<!-- llvm-hackme-state: bug_found -->
<!-- llvm-hackme-baseline: 08d281fe7a907089789be2c6ca6577cf3aac5629 -->
<!-- llvm-hackme-head-sha: 8b23469186bd1c61af886df1ac50d970d2f4e555 -->
<!-- llvm-hackme-patch-sha256: 5c30c6f51e2584cc48057cee93dc6c76ee722167c12f5c832380a6659b4b5f25 -->
<!-- llvm-hackme-kind: crash -->

This comment is generated by an automated correctness checking service designed to help identify critical correctness bugs (opt crashes or Alive2 miscompilations) and improve PR review efficiency under limited reviewer bandwidth.

## Reproducer

**Kind**: crash

**IR Reproducer**:
```llvm
; RUN: opt -passes=vector-combine -S
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

define void @crash(ptr %q, i16 zeroext %s, i32 %x) {
  %masked = and i32 %x, 7
  %ld = load <8 x i16>, ptr %q
  %v1 = insertelement <8 x i16> %ld, i16 %s, i32 %masked
  store <8 x i16> %v1, ptr %q
  ret void
}
```

**Stacktrace**:
```
opt: ../llvm-project-pr/llvm/lib/Transforms/Vectorize/VectorCombine.cpp:1842: {anonymous}::ScalarizationResult::~ScalarizationResult(): Assertion `!ToFreeze && "freeze() not called with ToFreeze being set"' failed.
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: /llvm-hackme/work/llvm-hackme/llvm-build-pr/bin/opt -S -o /dev/null /tmp/tmp558ltgkh.ll -passes=vector-combine
1.	Running pass "function(vector-combine)" on module "/tmp/tmp558ltgkh.ll"
2.	Running pass "vector-combine" on function "crash"
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  libLLVMSupport.so.23.0git       0x00007ffff7e189d2 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 66
1  libLLVMSupport.so.23.0git       0x00007ffff7e154ac llvm::sys::RunSignalHandlers() + 76
2  libLLVMSupport.so.23.0git       0x00007ffff7e156b1
3  libc.so.6                       0x00007ffff7a19520
4  libc.so.6                       0x00007ffff7a6d9fc pthread_kill + 300
5  libc.so.6                       0x00007ffff7a19476 raise + 22
6  libc.so.6                       0x00007ffff79ff7f3 abort + 211
7  libc.so.6                       0x00007ffff79ff71b
8  libc.so.6                       0x00007ffff7a10e96
9  libLLVMVectorize.so.23.0git     0x00007ffff0ac12f5
10 libLLVMVectorize.so.23.0git     0x00007ffff0ad8617
11 libLLVMVectorize.so.23.0git     0x00007ffff0af59d3
12 libLLVMVectorize.so.23.0git     0x00007ffff0af85b1 llvm::VectorCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) + 2017
13 libLLVMPasses.so.23.0git        0x00007ffff14fcf76
14 libLLVMCore.so.23.0git          0x00007fffee0f7fdd llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) + 381
15 libLLVMAMDGPUCodeGen.so.23.0git 0x00007ffff58db156
16 libLLVMCore.so.23.0git          0x00007fffee0f8477 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) + 439
17 libLLVMOptDriver.so.23.0git     0x00007ffff7f84b46
18 libLLVMCore.so.23.0git          0x00007fffee0f574f llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) + 319
19 libLLVMOptDriver.so.23.0git     0x00007ffff7f918a4 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) + 6068
20 libLLVMOptDriver.so.23.0git     0x00007ffff7f9f39c optMain + 16412
21 libc.so.6                       0x00007ffff7a00d90
22 libc.so.6                       0x00007ffff7a00e40 __libc_start_main + 128
23 opt                             0x0000555555555095 _start + 37
```


**Baseline Revision**: `08d281fe7a907089789be2c6ca6577cf3aac5629`
**PR Head SHA**: `8b23469186bd1c61af886df1ac50d970d2f4e555`
**Patch SHA256**: `5c30c6f51e2584cc48057cee93dc6c76ee722167c12f5c832380a6659b4b5f25`


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


More information about the llvm-commits mailing list