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

    <tr>
        <th>Summary</th>
        <td>
            [AMDGPU] crash when compiling ir since llc 18
        </td>
    </tr>

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

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

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

<pre>
    # Description
Interestingly, compiling IR with llc 18 results in a crash, but versions prior to llc 17 do not.

# Minimal Reproduction
https://llvm.godbolt.org/z/TqPhzqzYY

## Code
```
@G = global i64 0

define double @f() {
BB:
  %A = alloca i64, align 8
  store i64 0, ptr %A, align 4
  ret double 0.000000e+00
}

define i32 @main() {
    call double @f()
 ret i32 0
}
```
## Stack
```
LLVM ERROR: Cannot select: 0x9319330: ch = store<(store (s32) into %ir.A + 4, basealign 8)> 0x923a748, Constant:i32<0>, 0x9319640, undef:i64
  0x9318e60: i32 = Constant<0>
 0x9319640: i64 = bitcast 0x93195d0
    0x93195d0: v2i32 = BUILD_VECTOR 0x9319560, 0x9319480
      0x9319560: i32 = or 0x9319410, Constant:i32<4>
        0x9319410: i32 = extract_vector_elt 0x93192c0, Constant:i32<0>
          0x93192c0: v2i32 = bitcast FrameIndex:i64<0>
 0x9318c30: i64 = FrameIndex<0>
          0x9318e60: i32 = Constant<0>
        0x93194f0: i32 = Constant<4>
      0x9319480: i32 = extract_vector_elt 0x93192c0, Constant:i32<1>
        0x93192c0: v2i32 = bitcast FrameIndex:i64<0>
          0x9318c30: i64 = FrameIndex<0>
 0x9319170: i32 = Constant<1>
  0x9318ca0: i64 = undef
In function: f
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /opt/compiler-explorer/clang-trunk/bin/llc -o /app/output.s -x86-asm-syntax=intel -mtriple=amdgcn <source>
1.      Running pass 'CallGraph Pass Manager' on module '<source>'.
2.      Running pass 'AMDGPU DAG->DAG Pattern Instruction Selection' on function '@f'
 #0 0x0000000003749208 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/llc+0x3749208)
 #1 0x0000000003746bac SignalHandler(int) Signals.cpp:0:0
 #2 0x0000754fa2642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x0000754fa26969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #4 0x0000754fa2642476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #5 0x0000754fa26287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #6 0x000000000072d7c4 llvm::UniqueStringSaver::save(llvm::StringRef) (.cold) StringSaver.cpp:0:0
 #7 0x000000000350c98c llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) (/opt/compiler-explorer/clang-trunk/bin/llc+0x350c98c)
 #8 0x0000000003513db5 llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/opt/compiler-explorer/clang-trunk/bin/llc+0x3513db5)
 #9 0x0000000000f6818a AMDGPUDAGToDAGISel::Select(llvm::SDNode*) (/opt/compiler-explorer/clang-trunk/bin/llc+0xf6818a)
#10 0x0000000003509ef4 llvm::SelectionDAGISel::DoInstructionSelection() (/opt/compiler-explorer/clang-trunk/bin/llc+0x3509ef4)
#11 0x0000000003519101 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-trunk/bin/llc+0x3519101)
#12 0x000000000351bb59 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-trunk/bin/llc+0x351bb59)
#13 0x000000000351dac4 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-trunk/bin/llc+0x351dac4)
#14 0x0000000000f70295 AMDGPUDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-trunk/bin/llc+0xf70295)
#15 0x000000000350d7a1 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-trunk/bin/llc+0x350d7a1)
#16 0x0000000002848c0b llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#17 0x0000000002d83cc2 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/llc+0x2d83cc2)
#18 0x0000000002356e20 (anonymous namespace)::CGPassManager::runOnModule(llvm::Module&) CallGraphSCCPass.cpp:0:0
#19 0x0000000002d85af0 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/llc+0x2d85af0)
#20 0x000000000084a924 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#21 0x0000000000740326 main (/opt/compiler-explorer/clang-trunk/bin/llc+0x740326)
#22 0x0000754fa2629d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#23 0x0000754fa2629e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#24 0x000000000084256e _start (/opt/compiler-explorer/clang-trunk/bin/llc+0x84256e)
Program terminated with signal: SIGSEGV
Compiler returned: 139
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEWN1u2zwSfRrmZmCDJmX9XPjCsWJvgGQbJG2BXgUURcvcUqRKUanTp19QkmPJcbZN28UX9Mchh2cOD4czY7K6loUWYoHml2ieXrDG7YxdpLL4YFNTXGQmf14gQiEVNbeyctJohFOEl9faCStqJ3WhnhFZATdlJZXUBVzfw3fpdqAUh1kMVtSNcjVIDQy4ZfXOm2eNgydha2l0DZWVxoIz3ZIIcgPauGnnqf-XULiVWpZMwb2orMkbfmSzc66qEV0iskZkrdRTOS1MnhnlpsYWiKx_ILL--O1u9-Pbjy9fTnA99Mrkoh8Icf-n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