<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/124538>124538</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
GlobalISel BUILD_VECTOR hurts performance with more masks
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:AMDGPU,
llvm:globalisel
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
tpopp
</td>
</tr>
</table>
<pre>
I'm not sure about the tradeoffs of BUILD_VECTOR, so I'm not sure how to find and avoid cases where this does benefit codegen.
https://godbolt.org/z/369z3hqv9
# To Reproduce
A command like `llc -march=amdgcn -mtriple=amdgcn-amd-amdhsa -mcpu=gfx942 -global-isel` can be used on the IR
# Symptom and Cause
Various commands like `v_and_b32_e32 v3, 0xffff, v7` appear when constructing the BUILD_VECTOR result.
If `CombinerHelper::matchCombineInsertVecElts` is disabled, these masks go away and I've seen noticeable performance improvements in the full program that I'm running.
https://github.com/llvm/llvm-project/blob/6087c3049656bbaef51fffb48e2404e86f7e0d3f/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp#L3015
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUlMtv2zgQxv8a-jKwIZF62AcdXKfOGuhiF2mba8DHUOKGDy1JOU3_-gWVtEkXe9kDYWOk0Xzz-z6Jp2RGjziQ9gNpbzZ8yVOIQ57DPG9EUM_DhdDegQ8Z0hIRuAhLhjwh5MgVBq0TBA0fvl4-3Tzcfzx9-eOO0BOkAP9qnMIT5ADaeAW8nGswCiRPmOBpwoiQJ5NABUwg0KM2GWRQOKLfkepIquOU85wIOxJ6JvQ8BiWCzbsQR0LP3wk9s-7wnU1_Xw8vtxPK4EuAO5xjUIvEl-oRZHCuCLDmEYF0lbUSto5HORF2w50apYety9HMFn9WttypcqbEYevkvBB2M-pvh4bCdrRBcLs1CS3pKpDcg0BYEioIfkV1uXuT9PnZzTm4lcGJL6nouufRhCX9kJZ-ars-cK8eBKMPyChcWUFbfdNa6_Lv2pd5fJ6Rx8LQgww-5bjIbPy4Tn7vC0RMi82vNC-6DDgFJ4zH-BvaGWOBy46OZzm9Xrj4hDHfo_xocyrTikUmcWFRFQl5woTgeHpMMAbgT_x53ayYf0VIiL5EwEgsLTBj1CE67iWCcXMMV3TocwLzAkov1sIcwxi5gzzx_JqiuHhv_PjfQTB5WsROBkfo2drrj5_tHMNfKDOhZ2GDIPTcVftesqo5dG0nBEfd1lpr0eyRNlWD-073WCmm3z3HlL5TUHiLntDz7Wr15TPatfye3U7OM6HsE6vqllTHjRqYOrAD3-BQ96w_7Cnrq8009Ix3WnBx2IumahlVijNe1xRVxTps6MYMtKJtVdO-pi1tq12jRNf02La0rlFJRZoKHTd2V0SW_G9MSgsONW1att9YLtCm9YWmVHD5iF4Rdjz-fnP751dCKaEnQum6IDu-ZHeNLqXlAxCHlZ1YxkSaypqU09ucbLLF4Q3Cr_GalpjTLxY_mTyBC_E1IZsl2uF_m7culwg9v-53Heg_AQAA___s8oiF">