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

    <tr>
        <th>Summary</th>
        <td>
            Miscompile with slp-vectorizer after "[SLP][NFC]Walk over entries, not single values."
        </td>
    </tr>

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

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

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

<pre>
    llvm commit: d838e5b3e86e
Reproduce with
```opt -mtriple=aarch64 -passes=slp-vectorizer bbi-95270.ll -S -o - -slp-threshold=-100```
Result:
```
define i16 @foo() {
entry:
 %lnot = xor i1 false, true
  %lnot.ext = zext i1 %lnot to i16
  %add = add nsw i16 0, %lnot.ext
  %lnot5 = xor i1 false, true
  %lnot.ext6 = zext i1 %lnot5 to i16
  %add7 = add nsw i16 %add, %lnot.ext6
  ret i16 %add7
}
```
The input program returns 0, but after slp-vectorizer you can see that the function returns 2.
This starts happening with https://github.com/llvm/llvm-project/commit/938a73422e0b964eba16f272acdfae1d0281772c
The patch says "[SLP][NFC]Walk over entries, not single values." but it seems to not be NFC.
 
Before that patch we get
```
define i16 @foo() {
entry:
  %lnot = xor i1 true, true
  %lnot.ext = zext i1 %lnot to i16
  %add = add nsw i16 0, %lnot.ext
  %lnot5 = xor i1 true, true
 %lnot.ext6 = zext i1 %lnot5 to i16
  %add7 = add nsw i16 %add, %lnot.ext6
  ret i16 %add7
}
```
which still returns 0 as it should.
Note the difference in the "xor" instructions.
[bbi-95270.ll.gz](https://github.com/llvm/llvm-project/files/15233200/bbi-95270.ll.gz)

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMlVuPqzYQxz-NeRmBzHALDzycLMpTu6p6KvXZmCG4x2Bkm719-sqQza7SvKxaqUeK5MSZy39mfraFc-o8EzWsOLKijcTqR2ObSf0QpEejJ5qjzv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