<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/57548>57548</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[llvm-mca][X86] Crash with alderlake scheduler model
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:X86,
tools:llvm-mca,
backend:X86 Scheduler Models
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
RKSimon
</td>
</tr>
</table>
<pre>
https://llvm.godbolt.org/z/q6qfPbdaK
```
code_snippet:
vpmovzxbq %xmm1, %xmm1
vpsllw %xmm1, %ymm0, %ymm0
vpcmpeqd %xmm2, %xmm2, %xmm2
vpsllw %xmm1, %xmm2, %xmm1
vpbroadcastb %xmm1, %ymm1
vpand %ymm1, %ymm0, %ymm0
```
llvm-mca -mcpu=alderlake
```
llvm-mca: /root/llvm-project/llvm/lib/MCA/HardwareUnits/ResourceManager.cpp:181: llvm::mca::ResourceRef llvm::mca::ResourceManager::selectPipe(uint64_t): Assertion `RS.isReady() && "No available units to select!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/llvm-mca -o /app/output.s -mcpu=alderlake <source>
#0 0x0000556196518a94 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
#1 0x00005561965166d4 SignalHandler(int) Signals.cpp:0:0
#2 0x00007fa31a417420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#3 0x00007fa319eea00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#4 0x00007fa319ec9859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#5 0x00007fa319ec9729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#6 0x00007fa319edafd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#7 0x00005561963b6b37 llvm::mca::ResourceManager::selectPipe(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/llvm-mca+0xa81b37)
#8 0x00005561963b843b llvm::mca::ResourceManager::issueInstruction(llvm::mca::InstrDesc const&, llvm::SmallVectorImpl<std::pair<std::pair<unsigned long, unsigned long>, llvm::mca::ResourceCycles>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llvm-mca+0xa8343b)
#9 0x00005561963b9e68 llvm::mca::Scheduler::issueInstructionImpl(llvm::mca::InstRef&, llvm::SmallVectorImpl<std::pair<std::pair<unsigned long, unsigned long>, llvm::mca::ResourceCycles>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llvm-mca+0xa84e68)
#10 0x00005561963bbd0e llvm::mca::Scheduler::issueInstruction(llvm::mca::InstRef&, llvm::SmallVectorImpl<std::pair<std::pair<unsigned long, unsigned long>, llvm::mca::ResourceCycles>>&, llvm::SmallVectorImpl<llvm::mca::InstRef>&, llvm::SmallVectorImpl<llvm::mca::InstRef>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llvm-mca+0xa86d0e)
#11 0x00005561963caa57 llvm::mca::ExecuteStage::issueInstruction(llvm::mca::InstRef&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llvm-mca+0xa95a57)
#12 0x00005561963cac43 llvm::mca::ExecuteStage::issueReadyInstructions() (/opt/compiler-explorer/clang-assertions-trunk/bin/llvm-mca+0xa95c43)
#13 0x00005561963caf41 llvm::mca::ExecuteStage::cycleStart() (/opt/compiler-explorer/clang-assertions-trunk/bin/llvm-mca+0xa95f41)
#14 0x00005561963c6b1e llvm::mca::Pipeline::runCycle() (/opt/compiler-explorer/clang-assertions-trunk/bin/llvm-mca+0xa91b1e)
#15 0x00005561963c715a llvm::mca::Pipeline::run() (/opt/compiler-explorer/clang-assertions-trunk/bin/llvm-mca+0xa9215a)
#16 0x0000556195f88c9f runPipeline(llvm::mca::Pipeline&) llvm-mca.cpp:0:0
#17 0x0000556195f4f57b main (/opt/compiler-explorer/clang-assertions-trunk/bin/llvm-mca+0x61a57b)
#18 0x00007fa319ecb083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#19 0x0000556195f841de _start (/opt/compiler-explorer/clang-assertions-trunk/bin/llvm-mca+0x64f1de)
Compiler returned: 139
```
I found this when running the costs script from D103695 to check shift-by-uniform costs
Removing either of the vpsllw ops seems to fix this
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzlWFtzmzgU_jX4RWMPIK4PfkiddJrpdicTd3f2zSOEwNoIRCSR2P31e4SxY4ibuln3YWc92AZdvvOd7-h2yGS-na-NabSDrxz_I1xCPFWzUuaZFGYmVQlF3-D7GD0Wd1lOPjvuteNe9b-R21_dI5U5W-maNw0zFq8rRP3nqank07dN9tg_O364qSrP8ReH21F7LcTzuN22qtzj21EXWjXsMUcDE_6LicHtGdaGXV4RzJQkOSXaZK8d2p5oT-p81277A4dGutqQTCtKEPw0rYOviciZEuSBvdkcQgCwH5WUpo_rtFHyb0b3j_aPZ_D7ZWGD_4mo_Jko9kfNjYbne6Zlqyj7QmpSMjWjTQOQXuJZ4K4_xBhf7SzBtW9_z4q3qnu4XaFmAvjc8YY5ftLy2kTBCuil1sSV1kwZLmsErt0vZ1zfM5JvoSE0AM8iuODP_10i8kS4IJlgqLXkkZFoh-z4IDTEMEYFtGD5bCfR3W83V8sbpNus4gYRlLUlUqyRytiuwwlRcrNusxmV1ZFsQzG51i2zkiEbYl5T0eYMmTVDVBG9RhmhD0YRynrzSwMFKG-r5jBNXKhK75QsFakQUWVbsdroPoSysVaAQQM-qCnbNEIqkBDKBKnLKdkrpadGtfUDVGS83vPsRo60OAQiCGitaVoz06-HE3LwYhckB9_0o9fxsYvcjQufMIy8NAq9hKQBulMQrc6Rr9azJS9rIj6B_8ISS54kzx3_ykZqV6X78eN23wO2N8KOojxAYzCw9EMgvweKC4I9Enhx4LtotVJMG9BqBZHtBk4_4jdJtIqCqeB1u5mWdburaMxawRCbaTmDSfnB3XgBoNjheD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