<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64568>64568</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[SLPVectorizer] Crash during horizontal reduction (size() >= N && "Dropping more elements than exist")
</td>
</tr>
<tr>
<th>Labels</th>
<td>
llvm:SLPVectorizer,
crash
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
annamthomas
</td>
</tr>
</table>
<pre>
We crash in SLPVectorizer during horizontal reduction stating we remove more elements than present in the ArrayRef.
Here's reproducer.
cat upstream.ll
```
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2"
target triple = "x86_64-unknown-linux-gnu"
define void @ham.27() #0 {
bb:
br label %bb169
bb169: ; preds = %bb
%shl183 = shl i32 0, 6
%shl187 = shl i32 0, 8
%or188 = or i32 %shl183, 1
%add189 = add i32 %or188, %shl183
%add190 = add i32 0, %add189
%shl191 = shl i32 0, 10
%or192 = or i32 %shl187, 1
%add193 = add i32 %or192, %shl187
%add194 = add i32 %add190, %add193
%or196 = or i32 %shl191, 1
%add197 = add i32 %or196, %shl191
%add198 = add i32 %add194, %add197
%shl199 = shl i32 0, 14
%add202 = add i32 %add198, poison
%or203 = or i32 %shl199, 1
%add204 = add i32 %or203, %shl199
%add205 = add i32 %add202, %add204
%sub206 = sub i32 poison, %add205
store atomic i32 %sub206, ptr addrspace(1) poison unordered, align 4
unreachable
}
```
Reproduce with `opt -passes=slp-vectorizer upstream.ll -debug -mattr=+avx`
Failure is Assertion failed: (size() >= N && "Dropping more elements than exist"), function drop_back, file ArrayRef.h, line 211.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVU-P46gT_TTkghzhwn8POaQnv-h3WK1WM9LucYRNJWYHgwW4p2c-_QqcTDtpa08rJRUD71VeFXI94b26GsQDKV9I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