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

    <tr>
        <th>Summary</th>
        <td>
            [LoopIdiomRecognizer] creates memset_pattern16 with incorrect size type with custom dl
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            miscompilation,
            llvm:optimizations
      </td>
    </tr>

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

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

<pre>
    Take, e.g., `Transforms/LoopIdiom/unroll-custom-dl.ll`. It creates this call:

```llvm
; 64-bit size, 32-bit offset
target datalayout = "e-p:64:64:64:32-..."

  call void @memset_pattern16(i8* %f1, i8* bitcast ([4 x i32]* @.memset_pattern to i8*), i32 %3)
```

TargetLibraryInfo.def has this:
```c++
/// void memset_pattern16(void *b, const void *pattern16, size_t len);
TLI_DEFINE_ENUM_INTERNAL(memset_pattern16)
TLI_DEFINE_STRING_INTERNAL("memset_pattern16")
TLI_DEFINE_SIG_INTERNAL(Void, Ptr, Ptr, SizeT)
```

The end result is that the function isn't recognized as a libcall as there's a mismatch.
I believe the code shouldn't be using the index type for the last argument.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyFVN9vmzAQ_mvgxQoCm5DwwEPapBNSFk1dttfIYAPeDEa2ydr-9Tubpk3WSpMsG9-P774731Ep9lwc6W8e4HvEozZyZ5DFR00H0yjdmwA_7JUaSyZUD9_ToJWUi3oyVvULJiMpwTxCpUW15tRyg2wnDKopKMgmiLdBfNmzeF5SnvtXEblDWbqohEVGvHgSBPurahrD7WxlqW65RYxaKumzmiwKyBYFGPPFCDGy9GYDgCiCPPB1bOQJobMSDAVp3PMe0E8jtZbrIckCvBbrAG8AdNkkjsZ8BSY1NRAPr4PlXYqekCA4WG69aRpHtzjIqtkvwLnHINgBEne9rcA1taPPbi8qTfVzOTQqYrxBHZ0L-V7Di28d4Du3Zil-mNec2id5zSnjTeUY1WqAbC6iK7N7X_-TRZIPji55xT_uy9N291Aedqfd4cfXU3k47h4Pmz0Af4yVf_D5fnwsD1-uveBdPjriT33LG8efQNrx_Gb11fEdWB__U9-OIz4wpLmZpEXC1ZVa2DhqpqG2Qg0ghKxXFmxq1Q6AyRDUnyIpKt83_jG4hgZdOXEvTE9t3UVzhBJVXAp-5h60Vowj06lJshm04mgyYmi9VgyMPyH7PEJ0pb1Iug6DJph6Ptgo5EWSZTiPVwkmISsIy0lOQyus5AU04dswPl64amjIt-H7t7joj7AdRK2VhuTmMZvDe8U8x4jJcNKy6Kwdfcf5lmrBYKqi2s-9n9n5WIxa_QIsuApjJu5-EctVtsrDrsgqlmbJkpHVKsMYNxXBZJnHWU5Tskp5EkoKtTIuEdcJwgD6KCR1r-D74N7NtQ9GNmq0ohcvXmmcdrkNRYFjjOM8SZKUrFMcMZo0NVmv19WSE84yGEveU-F-TOc-UroNdeFZV1NrQCmFseZdSY0R7cB9aR0-nWyndDFMgxqlGrkJfY6FT_AvbQKWzg">