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

    <tr>
        <th>Summary</th>
        <td>
            llvm.ptrmask broken on arm64_32: Pointers with different index type are not supported by SDAG
        </td>
    </tr>

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

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

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

<pre>
    The two checks added in eb86de63d901941fba0a54eb41551456447cd789, one in the Verifier and the other in SelectionDAGBuilder.cpp don't quite agree. The Verifier's respects the DataLayout, but the one in SelectionDAG only inspects the in-register type of a pointer, which on arm64_32 differs from its in-memory size.

```
$ cat reduced.ll 
target datalayout = "e-m:o-p:32:32-i64:64-i128:128-n32:64-S128"
target triple = "arm64_32-apple-watchos11.0.0"

define void @rdar125263567() {
entry:
  %aligned_result.i101.i = call ptr @llvm.ptrmask.p0.i32(ptr null, i32 0)
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare ptr @llvm.ptrmask.p0.i32(ptr, i32) #0

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
```

```
$ ./bin/llc reduced.ll
Assertion failed: (PtrVT == Mask.getValueType() && "Pointers with different index type are not supported by SDAG"), function visitIntrinsicCall, file SelectionDAGBuilder.cpp, line 7847.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: ./bin/llc reduced.ll
1.      Running pass 'Function Pass Manager' on module 'reduced.ll'.
2.      Running pass 'AArch64 Instruction Selection' on function '@rdar125263567'
 #0 0x0000000105adb594 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/Users/jonathan_roelofs/llvm-upstream/build/bin/llc+0x103667594)
 #1 0x0000000105adbbb8 PrintStackTraceSignalHandler(void*) (/Users/jonathan_roelofs/llvm-upstream/build/bin/llc+0x103667bb8)
 #2 0x0000000105ad97d4 llvm::sys::RunSignalHandlers() (/Users/jonathan_roelofs/llvm-upstream/build/bin/llc+0x1036657d4)
 #3 0x0000000105adccd4 SignalHandler(int) (/Users/jonathan_roelofs/llvm-upstream/build/bin/llc+0x103668cd4)
 #4 0x0000000192e6eb44 (/usr/lib/system/libsystem_platform.dylib+0x180486b44)
 #5 0x0000000192e37bcc (/usr/lib/system/libsystem_pthread.dylib+0x18044fbcc)
 #6 0x0000000192d44900 (/usr/lib/system/libsystem_c.dylib+0x18035c900)
 #7 0x0000000192d43c24 (/usr/lib/system/libsystem_c.dylib+0x18035bc24)
 #8 0x0000000105769048 llvm::SelectionDAGBuilder::visitIntrinsicCall(llvm::CallInst const&, unsigned int) (/Users/jonathan_roelofs/llvm-upstream/build/bin/llc+0x1032f5048)
 #9 0x000000010574312c llvm::SelectionDAGBuilder::visitCall(llvm::CallInst const&) (/Users/jonathan_roelofs/llvm-upstream/build/bin/llc+0x1032cf12c)
<snip>
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0V11v47oR_TX0y8CCRFFfD35wkvXtBe4Fgpt0XwOKHFncUKRKUsm6v76gZCe2d7cN2tQIFEskZ86cOTMac-_V3iBuSHFDirsVn0Jv3eabs6ht51etlYfNY48QXi2IHsWzBy4lSlAGsK1LiWUumzRrWNa1POUFw5ZlRZGxomSsErKqG0JvwRqMR0KP8BWd6hQ64EbOD2zo0cXVB9QogrLmbvvbzaS0RJeIcQRpDaFVgH9MKiDwvUNM4PHMFKGVB4d-RBH8bPOOB_4HP9gpRO_tFBZPC4pzP2CNPoAyZ2eVWTvcKx_QQTiMCLYDDqNVJkRXt_DaK9GDNcDdULKnnIJUXYfOQ-fsACr4aGPAwboDePVPTEh6R9Lt8Vqmx7_lljIQPIBDOQmUidawLATu9hhA8sD1HAmQ_A4IpbgeSL6165Hk25zOl7UqGcm3JVurjNYk32a0Xpt5sWTrh_iM0guzwalR48nk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