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

    <tr>
        <th>Summary</th>
        <td>
            [VPlan] Recipe fo splat operation
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            vectorizers,
            vectorization
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          Mel-Chen
      </td>
    </tr>
</table>

<pre>
    While trying to re-implement min/max with index, I discovered this potential bug.
```
middle.block:
  EMIT vp<%8> = compute-reduction-result ir<%max.09>, ir<%1>
  EMIT vp<%9> = icmp eq ir<%1>, vp<%8>
```
Currently, it seems there’s no check to ensure the vector preheader dominates the definition before hoisting the splat to the vector preheader. This could result in a use-before-definition issue.

For now, I’ve temporarily reverted SafeToHoist to an earlier setting, but I think the best approach would likely be to introduce a dedicated VPInstruction::Splat.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxsk09vrDYUxT-N2VwNAjN_YMEinWTULJ701Be9ro19MrgxNrUvk0w_fWUmaV-kSAjkK_Pzuef4qpTs2QO92P0mdveFWngMsf8GtzmO8MUQzLX_c7QOxPFq_Zk4UMTGTrPDBM80WS_kaVJv9Gp5JOsN3oQ80iMZm3S4IMIQjzbRHBierXI0LOdSVPeiuhP76v1Zl5M1xqEcXNAvorm7FYkevj0-0WUWzVHIXSuaBxLNPekwzQtjE2EWzTb4TURaHJONt52TeiurTjQPWc9Hsc7rr7jdB9fqaSb8_fkPefwk4Ev1xyVGeHbX9TymBEyJeESEeJCirUTXJfKB9Aj9kp2ET0tE3kIXaA6R5ogRyiCSCZP1irESyODZepu7pAHPIYLGYBOviYygNDvFmfgVqqSn7L8OizP04ZEnRUvC5kbb_MK3KS34yGd9n0IkH17XWP_r5AJiTHOIKlp3pYgLIsPQD_WMp_B7VpcFKU9Q0VlESuAsOGOGhekxXwv_skoekJjUPMeg9Eivq1JnX-CuNCBjrOcYzKJBigyM1Sqf9fP7o08cb_HnC9Pc_chOlIXpG9M1nSrQ14dG1u2u6qpi7A8GbbVv0Sml28O2U7VC1RzUbrvbt3vVFLaXldzWtazrqqmbqqw606I1UnXY6329FdsKk7KudO4ylSGei9Wwvq4PddMVTg1waZ0nKW9J2H8Qk5BSyOMvNbVqljKPXewzbDMs5yS2lbOJ0_94tuzWAf353Skvdvf0B7SdQc_hPfcwI664YomuH5nnlM2QJyFPZ8vjMpQ6TEKeMvP9s5lj-AuahTyt-pOQp_cWLr38NwAA__9BUVGS">