<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/185556>185556</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Missed Optimization: Failure to narrow a wide vector load and adjust GEP offset when only trailing elements are used.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Leo0506
      </td>
    </tr>
</table>

<pre>
    ```
define <2 x float> @src(ptr %arg0) {
 %v0 = getelementptr inbounds nuw i8, ptr %arg0, i64 40
  %v1 = load <4 x float>, ptr %v0, align 8
  %v2 = shufflevector <4 x float> %v1, <4 x float> poison, <2 x i32> <i32 2, i32 3>
  ret <2 x float> %v2
}

define <2 x float> @tgt(ptr %arg0) {
  %v0 = getelementptr inbounds nuw i8, ptr %arg0, i64 48
  %v1 = load <2 x float>, ptr %v0, align 8
  ret <2 x float> %v1
}
```
Godbolt: https://godbolt.org/z/1nKbrnxfM
alive2: https://alive2.llvm.org/ce/z/DZj48j
Pattern found in: https://github.com/dtcxzyw/llvm-opt-benchmark/blob/main/bench/pbrt-v4/optimized/camera.ll
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJykU8GO2zYQ_ZrRZbAGNZRs-aCDsxvl0AbNuTdKHMl0KdIgKXt3v76g7CbbpBsUCCAIEEfvzXuPMypGMznmFuoPUD8VaklHH9rf2YtabIve65cWtuL-iIPm0ThGkI-EzzharxLIjwiViGEAas4pIFCtwiSA9gi7DyAO-eQiEOQTTpzY8swu5T-N6_3idES3XNE0QI_4L4JHNNsKq9wYV5JyJbFe6SyheiPhDfayIpU1k8PmK5RWaDwu42j5wkPy4XuOW4sM_r5w9iZ6d69k50bSCpCPRhLSKlUSyqwkdwycfgwpqwBxgN1Tfv8szDSld8P81TSbd9Kk_5vme97Kb97eTMwnr3tvE8gDHlM6R5AHoA6om26FjQ8TUPcK1JXutz645_EziIOy5sL0I-p2vrH2Mt-RA9_hT3-equYE4vBFpcTB4ZjjQOP-o7dJx6XfDH4G6nQanl9frkBdZn3w5_TQsxuOswp_AXW99T1QNyvj8leuAHXnPqSHSwXU-XMys3llnbWomYPaWFvoVuq93KuC23K3k6XYV7uyOLY996Kuh2ovB7lXPIhGShKylNRQr3dNYVoStBWyFIKokuVGsdhV5VgRV3rYVQSV4FkZ-zWDwsS4cFs2dV1vC6t6tnHdZyLHV1yrQJTXO7SrxX6ZIlTCmpjiN5pkkuX2s4mRNf5xc6WS8Wt-nTJ2CYzJo1Mh-CsqvBrNeF-ldYqU06j0aYkJP338gn4cIye8Htmhd_YFU1DGGjfhfWojqsC4RNabYgm2_cklZZX_3NA5-BMPCahbvcU8Ojfzl5b-DgAA__9-53MX">