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

    <tr>
        <th>Summary</th>
        <td>
            [LoopVectorize] Failure to compare multiple inputs as the same (splatted) value
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            bug,
            llvm:codegen,
            loopoptim
      </td>
    </tr>

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

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

<pre>
    Pulled out of a regression report on https://reviews.llvm.org/rGfed28ada47f5/ fed28ada47f5

> > > I haven't done a great job with reducing this - but this shows the effect - https://gcc.godbolt.org/z/5q36ExYqa - loop-vectorize creates the `icmp ne <2 x i64> %24, undef` and then instcombine simplifies it all - but I'm still not certain that LV is at fault or not [@fhahn](https://reviews.llvm.org/p/fhahn/) do you have any suggestions?

> > That's a very interesting case! It looks like this is indeed a LV miscompile. The issue is that we introduce multiple new uses of undef. The issue is that each use of undef could take different values, whereas the code we generate relies that we compare against the same value. See https://alive2.llvm.org/ce/z/osWdyX for Alive2 showing the issue (the input is a further reduced version of the test case)

> > I think we need to insert a freeze, then broadcast it to a vector and consistently use that in the generated code instead of undef: https://alive2.llvm.org/ce/z/HT7J6u. I can look into a patch for this

> FTR this also is an issue for arbitrary inputs, not just poison/undef constants: https://alive2.llvm.org/ce/z/5BsKqY

CC @fhahn @alexfh 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUlUFv2zgThn8NfRnYUGhLsg8-pEn9fdn2sGiD7vY4EkcSG4pUyaFd99cvSNlJNwiwu4AtS8SQmnnfZ8YYgu4t0V6U70R5v8DIg_P7Tx8-69HZRePUef97NIYUuMjgOkDw1HsKQTsLnibnGZyFgXkKYn0r5EHIg6ejplNYGXMcV873ael_HSm5RYWbuiuFPMDfnot7Udxeruv3cP0-wIBHskLWDMpZAoTeEzJ8cw2cNA_gScV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