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

    <tr>
        <th>Summary</th>
        <td>
            [LoopVectorizer]  Assertion "Packing must reduce size of vector type."' failed.
        </td>
    </tr>

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

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

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

<pre>
    It seems that LoopVectorizer is generating a TTI query for a truncate from i1 to i8, which is wrong.

LoopVectorize.cpp:7080

```
return TTI.getCastInstrCost(Opcode, VectorTy, SrcVecTy, CCH, CostKind, I);

(gdb) p Opcode
$234 = 38
(gdb) p (int) Instruction::Trunc
$235 = 38
(gdb) p VectorTy->dump()
<2 x i8>
$236 = void
(gdb) p SrcVecTy->dump()
<2 x i1>
$237 = void
```
[tc_tti_lv.tar.gz](https://github.com/llvm/llvm-project/files/14384809/tc_tti_lv.tar.gz)

opt -mtriple=s390x-unknown-linux -mcpu=z16 -O3 -S ./tc_tti_lv.ll

SystemZTargetTransformInfo.cpp:661: unsigned int llvm::SystemZTTIImpl::getVectorTruncCost(llvm::Type*, llvm::Type*): Assertion `SrcTy->getPrimitiveSizeInBits().getFixedValue() > DstTy->getPrimitiveSizeInBits().getFixedValue() && "Packing must reduce size of vector type."' failed.
#18 0x000000000381581c llvm::LoopVectorizePass::processLoop

@fhahn @david-arm @nilanjana87

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