<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 --- - SLPVectorizer asserts in buildtree_rec"
   href="https://llvm.org/bugs/show_bug.cgi?id=27617">27617</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>SLPVectorizer asserts in buildtree_rec
          </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>Linux
          </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>Loop Optimizer
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>jesper.antonsson@ericsson.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=16298" name="attach_16298" title="minimal llvm assembly language file that triggers the assert">attachment 16298</a> <a href="attachment.cgi?id=16298&action=edit" title="minimal llvm assembly language file that triggers the assert">[details]</a></span>
minimal llvm assembly language file that triggers the assert

For the attached ll code example and the invocation:
./build-all/bin/opt -S -mcpu=x86-64 -mtriple=x86_64-linux -indvars
-slp-vectorizer -O1 -o /dev/null foo.opt.ll

I get this assert:
opt: ../lib/Transforms/Vectorize/SLPVectorizer.cpp:1005: void (anonymous
namespace)::BoUpSLP::buildTree_rec(ArrayRef<llvm::Value *>, unsigned int):
Assertion `SameTy && "Invalid types!"' failed.

The problem is that two getelementpointer indicies have differing types. Both
have the value 4, but one is of i16 type and one is i64. The recursive call to
gather those values fails with an assert because the types differ.

The simplest fix might be to change the assert to allow this. Something like
this:
-  bool SameTy = getSameType(VL); (void)SameTy;
+  bool SameTy = allConstant(VL) || getSameType(VL); (void)SameTy;</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>