<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - SLP causes a miscompile"
   href="https://llvm.org/bugs/show_bug.cgi?id=31243">31243</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>SLP causes a miscompile
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Scalar Optimizations
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>michael.v.zolotukhin@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=17705" name="attach_17705" title="Reproducer">attachment 17705</a> <a href="attachment.cgi?id=17705&action=edit" title="Reproducer">[details]</a></span>
Reproducer

Reproducer (slp_bug.ll is attached):

<span class="quote">> llc -O0 slp_bug.ll   -o good.s
> clang -m32 -o good good.s</span >

<span class="quote">> opt -slp-vectorizer slp_bug.ll -o after_slp.ll -S
> llc -O0 after_slp.ll -o bad.s
> clang -m32 -o bad bad.s</span >

<span class="quote">> ./good
> echo $?</span >
106

<span class="quote">> ./bad
> echo $?</span >
0

The bug is that we sign-extend values, which should be zero-extended instead.
For instance, here:
  %10 = zext <4 x i8> %9 to <4 x i32>        ; Original value is zero-extended
  %11 = trunc <4 x i32> %10 to <4 x i8>      ; Now we truncate it...
  %12 = extractelement <4 x i8> %11, i32 0   ; extract first element...
  %13 = sext i8 %12 to i32                   ; and sign-extend it.
  ...

The issue seems to be introduced in r258929.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>