<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - [LoopVectorizer] getInstructionCost() triggers assert"
   href="https://bugs.llvm.org/show_bug.cgi?id=48321">48321</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[LoopVectorizer]  getInstructionCost() triggers assert
          </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>enhancement
          </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>paulsson@linux.vnet.ibm.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=24216" name="attach_24216" title="reduced testcase">attachment 24216</a> <a href="attachment.cgi?id=24216&action=edit" title="reduced testcase">[details]</a></span>
reduced testcase

LoopVectorizationCostModel::getInstructionCost is passed a trunc instruction:

%i11.i = trunc i40 %i10.i to i32

RetTy is first i32, but after

if (canTruncateToMinimalBitwidth(I, VF))
    RetTy = IntegerType::get(RetTy->getContext(), MinBWs[I]);

it is set to i1, which seems broken?

SystemZTTIImpl::getCastInstrCost() is then called:
(gdb) p Dst->dump()
<2 x i32>
$49 = void
(gdb) p Src->dump()
<2 x i1>

which triggers an assert since this would be a cost of truncating i1 vector to
i32 vector, which doesn't make sense...

./bin/opt -mcpu=z14 tc_sztti.ll -o a.out -O2</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>