xref: /llvm-project/llvm/test/Transforms/LoopStrengthReduce/AMDGPU/different-addrspace-crash.ll (revision 055fb7795aa219a3d274d280ec9129784f169f56)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: llc < %s | FileCheck %s
3
4target triple = "amdgcn--"
5
6; We need to compile this for a target where we have different address spaces,
7; and where pointers in those address spaces have different size.
8; E.g. for amdgcn-- pointers in address space 0 are 32 bits and pointers in
9; address space 1 are 64 bits.
10
11; We shouldn't crash. Check that we get a loop with the two stores.
12;CHECK-LABEL: foo:
13;CHECK: [[LOOP_LABEL:.LBB[0-9]+_[0-9]+]]:
14;CHECK: buffer_store_dword
15;CHECK: buffer_store_dword
16;CHECK: s_cbranch_vccnz [[LOOP_LABEL]]
17
18define amdgpu_kernel void @foo() {
19entry:
20  br label %loop
21
22loop:
23  %idx0 = phi i32 [ %next_idx0, %loop ], [ 0, %entry ]
24  %0 = getelementptr inbounds i32, ptr addrspace(5) null, i32 %idx0
25  %1 = getelementptr inbounds i32, ptr addrspace(1) null, i32 %idx0
26  store i32 1, ptr addrspace(5) %0
27  store i32 7, ptr addrspace(1) %1
28  %next_idx0 = add nuw nsw i32 %idx0, 1
29  br label %loop
30}
31
32