<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/144654>144654</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[VectorCombine] Recognise reduction patterns from extract+binop+shuffle chains
</td>
</tr>
<tr>
<th>Labels</th>
<td>
llvm:instcombine,
missed-optimization
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
RKSimon
</td>
</tr>
</table>
<pre>
```ll
define i16 @test_reduce_v8i16(<8 x i16> %a0) local_unnamed_addr #0 {
%1 = shufflevector <8 x i16> %a0, <8 x i16> poison, <8 x i32> <i32 4, i32 5, i32 6, i32 7, i32 poison, i32 poison, i32 poison, i32 poison>
%2 = tail call <8 x i16> @llvm.umin.v8i16(<8 x i16> %a0, <8 x i16> %1)
%3 = shufflevector <8 x i16> %2, <8 x i16> poison, <8 x i32> <i32 2, i32 3, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
%4 = tail call <8 x i16> @llvm.umin.v8i16(<8 x i16> %2, <8 x i16> %3)
%5 = shufflevector <8 x i16> %4, <8 x i16> poison, <8 x i32> <i32 1, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
%6 = tail call <8 x i16> @llvm.umin.v8i16(<8 x i16> %4, <8 x i16> %5)
%7 = extractelement <8 x i16> %6, i64 0
ret i16 %7
}
```
Recognise that patterns such as this can fold to a `llvm.vector.reduce.umin.v8i16(%a0)` intrinsic call (costs permitting)
Noticed when reviewing #144231
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy0lE2v6yYQhn8N3qAT4QF_ZOFFPm42lbq4lbqNCB7HU2GIDM697a-vcGLlKD2tcqtzpSge42HgfRheHQKdHWLDii0r9pmeYu_H5usvv9HgXXby7Z8NK8XtZy0TmxY7csgpLzlTImKIxxHbyeDxWlNeMqiZ3NX8e8pg8gtnUGjBYM2tN9oeJ-f0gO1Rt-3IGUjBWbVlYsNTYs6Z3PPQT11n8Yom-pF_WG33NHzxFLx7Py5hTpc7ksBV-pKCYgnKJaiW4FHixTf5Zdk2zNuOmiw32trnLSth7XVYTQO51X8yelaViDBYL8vIV-jAD8OBRZf83yhew6Q-AdMH8hKZd5SKVyipH6aU_xQ4_4aq_ARUH2hMeN6hquZV8HsctYlocUAX_znjdlVKxcU8b8R4u_xQVExsWLVP_4tFpFhsvqLxZ0cBeex15BcdI44u8DCZnuvAY0-BG-14523Lo-eaz_ZyHVa3E1vdLOVJ4d1JWCk4uTiSC2TufKA2PsTALzgOFCO5800nE5tffSSDLf_Wo-MjXgm_kTsn78mVAplnbSPbtVzrDJu8KgTISq4h6xuULXaAtZSiA6lEZYq8VnVd5KZAU5wyakBAIcq8Fmshc1hpVLJAUVWqk-tSaaYEDprsapbmx3NGIUzY5EqVhcqsPqENs_UCpBQmN-RCNH44kUMGqdsZwEAhYPvmL5EG-ktHSp0Dya7HJk17O03nkJqCQgyPtSJFOxv77zPT3b1qseeP85k5p4KPQ-pGPyxNwWB7IucvDLb3G8VNr8mFbBpt08d4CUxuGBwYHM4U--m0Mn5gcJjV3B5vl9H_ganWYVYfGBzuAK4N_B0AAP__YQLdig">