<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><p style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">Loading 2 2x32-bit float vectors into the bottom half of a 256-bit vector</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">produced suboptimal code in AVX2 mode with certain IR combinations.</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;" class=""><br class=""></p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">In particular, the IR optimizer folded 2f32 + 2f32 -> 4f32, 4f32 + 4f32</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">(undef) -> 8f32 into a 2f32 + 2f32 -> 8f32, which seems more canonical,</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">but then mysteriously generated rather bad code; the movq/movhpd combination</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">didn't match.</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;" class=""><br class=""></p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">The problem lay in the BUILD_VECTOR optimization path. The 2f32 inputs</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">would get promoted to 4f32 by the type legalizer, eventually resulting</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">in a BUILD_VECTOR on two 4f32 into an 8f32. The BUILD_VECTOR then, recognizing</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">these were both half the output size, concatted them and then produced</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">a shuffle. However, the resulting concat + shuffle was more complex than</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">it should be; in the case where the upper half of the output is undef, we</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">probably want to generate shuffle + concat instead.</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;" class=""><br class=""></p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">This enhancement results in the optimizer correctly producing the optimal</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">movq + movhpd sequence for all three variations on this IR, even with AVX2.</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;" class=""><br class=""></p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">I've included a test case.</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;" class=""><br class=""></p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">Radar link: <a href="rdar://problem/13326338" class="">rdar://problem/13326338</a></p><div class=""><br class=""></div><div class=""></div></body></html>