<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61749>61749</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Operand Index out of Range during Interleaved Access Pass (affecting X86 & ARM)
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
HazyFish
</td>
</tr>
</table>
<pre>
## Description
When targeting `x86_64`, `i686`, `aarch64`, or `arm`, the following code crashes latest LLC with assertion error `i < NumUserOperands && "getOperand() out of range!"` in `llvm/include/llvm/IR/User.h:170: llvm::Value* llvm::User::getOperand(unsigned int) const` during `Interleaved Access Pass`
The code can compile successfully when targeting `wasm32`, `wasm64`, `riscv32`, `riscv64`.
## Minimal Reproduction
### Code
```ll
define void @f(ptr %p0, ptr %p1, ptr %p2) {
entry:
%v0 = load <8 x i8>, ptr %p0
%v1 = add <8 x i8> %v0, <i8 0, i8 1, i8 2, i8 3, i8 7, i8 7, i8 7, i8 7>
%v2 = load <8 x i8>, ptr %p1
%shuffled = shufflevector <8 x i8> %v2, <8 x i8> %v1, <4 x i32> <i32 0, i32 2, i32 4, i32 6>
store <4 x i8> %shuffled, ptr %p2
ret void
}
```
### Stack Trace
```console
llc: /home/henry/IRFuzzer/llvm-project/llvm/include/llvm/IR/User.h:170: llvm::Value *llvm::User::getOperand(unsigned int) const: Assertion `i < NumUserOperands && "getOperand() out of range!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: ./build-debug/bin/llc ../tmp/crash-reports/1.ll --mtriple=x86_64
1. Running pass 'Function Pass Manager' on module '../tmp/crash-reports/1.ll'.
2. Running pass 'Interleaved Access Pass' on function '@f'
#0 0x00007fdea199f69d llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/henry/IRFuzzer/llvm-project/llvm/lib/Support/Unix/Signals.inc:565:11
#1 0x00007fdea199fb2b PrintStackTraceSignalHandler(void*) /home/henry/IRFuzzer/llvm-project/llvm/lib/Support/Unix/Signals.inc:639:1
#2 0x00007fdea199ddb6 llvm::sys::RunSignalHandlers() /home/henry/IRFuzzer/llvm-project/llvm/lib/Support/Signals.cpp:104:5
#3 0x00007fdea19a0345 SignalHandler(int) /home/henry/IRFuzzer/llvm-project/llvm/lib/Support/Unix/Signals.inc:410:1
#4 0x00007fdea119e520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#5 0x00007fdea11f2a7c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x96a7c)
#6 0x00007fdea119e476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#7 0x00007fdea11847f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#8 0x00007fdea118471b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#9 0x00007fdea1195e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#10 0x00007fdea4e4416e llvm::User::getOperand(unsigned int) const /home/henry/IRFuzzer/llvm-project/llvm/include/llvm/IR/User.h:0:5
#11 0x00007fdea509cc93 (anonymous namespace)::InterleavedAccess::lowerInterleavedLoad(llvm::LoadInst*, llvm::SmallVector<llvm::Instruction*, 32u>&) /home/henry/IRFuzzer/llvm-project/llvm/lib/CodeGen/InterleavedAccessPass.cpp:369:69
#12 0x00007fdea509c3cf (anonymous namespace)::InterleavedAccess::runOnFunction(llvm::Function&) /home/henry/IRFuzzer/llvm-project/llvm/lib/CodeGen/InterleavedAccessPass.cpp:538:18
#13 0x00007fdea23ea486 llvm::FPPassManager::runOnFunction(llvm::Function&) /home/henry/IRFuzzer/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1430:23
#14 0x00007fdea23ef2b2 llvm::FPPassManager::runOnModule(llvm::Module&) /home/henry/IRFuzzer/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1476:16
#15 0x00007fdea23ead59 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /home/henry/IRFuzzer/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1545:23
#16 0x00007fdea23ea8cd llvm::legacy::PassManagerImpl::run(llvm::Module&) /home/henry/IRFuzzer/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:535:16
#17 0x00007fdea23ef591 llvm::legacy::PassManager::run(llvm::Module&) /home/henry/IRFuzzer/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1672:3
#18 0x00005654ab542650 compileModule(char**, llvm::LLVMContext&) /home/henry/IRFuzzer/llvm-project/llvm/tools/llc/llc.cpp:736:41
#19 0x00005654ab540a2d main /home/henry/IRFuzzer/llvm-project/llvm/tools/llc/llc.cpp:420:13
#20 0x00007fdea1185d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#21 0x00007fdea1185e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#22 0x00005654ab540205 _start (./build-debug/bin/llc+0x19205)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMWNty27wRfhroBmMNuCBB8kIXihz194zd3-Okae88IAlKaEBQA4A-5Ok7ACnzkKSp3STtjMcUFsvdb49YglsrD1qIDUreoeRyxTt3bM3mD_7leS_tcVW01fMGAUVA8aWwpZEnJ1uNyCUi2_7_349CY8fNQTipDxgx8pSxexYjRhDs_FqyjI0rzk15fNluTaCZZli7o8B1q1T76IWVbSVwabg9CosVd8I6fH29w4_SHTG3VhiPBgtjejkSI7rDf-2av1lh_jwJw3VlMQKGgGEEcBBuoCLIEOS47Rxua2y4PggEEQJAjGCpvTClHhoEe6lL1VUCwX4gXN0h2HsF6yOi2ygliG5x2KNbRLefuOoEginJM_e_ZgA6HZxfYamdB1O22jqvv-rM4Mor7YRRgj-ICm_LUliLb7m13lmTEHw8isFVXOOybU5SCWy7wF93Sj3jx6-C9MhtQ2EMi19Pg2akLR-mDIEQONZT3UNy3EgtG67wnTiZturKZZb0bJ5z11ZitsNI_6dU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