• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -S -mtriple=amdgcn-unknown-amdhsa -mcpu=kaveri -amdgpu-promote-alloca < %s | FileCheck %s
2
3; This normally would be fixed by instcombine to be compare to the GEP
4; indices
5
6; CHECK-LABEL: @lds_promoted_alloca_icmp_same_derived_pointer(
7; CHECK: [[ARRAYGEP:%[0-9]+]] = getelementptr inbounds [256 x [16 x i32]], [256 x [16 x i32]] addrspace(3)* @lds_promoted_alloca_icmp_same_derived_pointer.alloca, i32 0, i32 %{{[0-9]+}}
8; CHECK: %ptr0 = getelementptr inbounds [16 x i32], [16 x i32] addrspace(3)* [[ARRAYGEP]], i32 0, i32 %a
9; CHECK: %ptr1 = getelementptr inbounds [16 x i32], [16 x i32] addrspace(3)* [[ARRAYGEP]], i32 0, i32 %b
10; CHECK: %cmp = icmp eq i32 addrspace(3)* %ptr0, %ptr1
11define void @lds_promoted_alloca_icmp_same_derived_pointer(i32 addrspace(1)* %out, i32 %a, i32 %b) #0 {
12  %alloca = alloca [16 x i32], align 4
13  %ptr0 = getelementptr inbounds [16 x i32], [16 x i32]* %alloca, i32 0, i32 %a
14  %ptr1 = getelementptr inbounds [16 x i32], [16 x i32]* %alloca, i32 0, i32 %b
15  %cmp = icmp eq i32* %ptr0, %ptr1
16  %zext = zext i1 %cmp to i32
17  store volatile i32 %zext, i32 addrspace(1)* %out
18  ret void
19}
20
21; CHECK-LABEL: @lds_promoted_alloca_icmp_null_rhs(
22; CHECK: [[ARRAYGEP:%[0-9]+]] = getelementptr inbounds [256 x [16 x i32]], [256 x [16 x i32]] addrspace(3)* @lds_promoted_alloca_icmp_null_rhs.alloca, i32 0, i32 %{{[0-9]+}}
23; CHECK: %ptr0 = getelementptr inbounds [16 x i32], [16 x i32] addrspace(3)* [[ARRAYGEP]], i32 0, i32 %a
24; CHECK: %cmp = icmp eq i32 addrspace(3)* %ptr0, null
25define void @lds_promoted_alloca_icmp_null_rhs(i32 addrspace(1)* %out, i32 %a, i32 %b) #0 {
26  %alloca = alloca [16 x i32], align 4
27  %ptr0 = getelementptr inbounds [16 x i32], [16 x i32]* %alloca, i32 0, i32 %a
28  %cmp = icmp eq i32* %ptr0, null
29  %zext = zext i1 %cmp to i32
30  store volatile i32 %zext, i32 addrspace(1)* %out
31  ret void
32}
33
34; CHECK-LABEL: @lds_promoted_alloca_icmp_null_lhs(
35; CHECK: [[ARRAYGEP:%[0-9]+]] = getelementptr inbounds [256 x [16 x i32]], [256 x [16 x i32]] addrspace(3)* @lds_promoted_alloca_icmp_null_lhs.alloca, i32 0, i32 %{{[0-9]+}}
36; CHECK: %ptr0 = getelementptr inbounds [16 x i32], [16 x i32] addrspace(3)* [[ARRAYGEP]], i32 0, i32 %a
37; CHECK: %cmp = icmp eq i32 addrspace(3)* null, %ptr0
38define void @lds_promoted_alloca_icmp_null_lhs(i32 addrspace(1)* %out, i32 %a, i32 %b) #0 {
39  %alloca = alloca [16 x i32], align 4
40  %ptr0 = getelementptr inbounds [16 x i32], [16 x i32]* %alloca, i32 0, i32 %a
41  %cmp = icmp eq i32* null, %ptr0
42  %zext = zext i1 %cmp to i32
43  store volatile i32 %zext, i32 addrspace(1)* %out
44  ret void
45}
46
47; CHECK-LABEL: @lds_promoted_alloca_icmp_unknown_ptr(
48; CHECK: %alloca = alloca [16 x i32], align 4
49; CHECK: %ptr0 = getelementptr inbounds [16 x i32], [16 x i32]* %alloca, i32 0, i32 %a
50; CHECK: %ptr1 = call i32* @get_unknown_pointer()
51; CHECK: %cmp = icmp eq i32* %ptr0, %ptr1
52define void @lds_promoted_alloca_icmp_unknown_ptr(i32 addrspace(1)* %out, i32 %a, i32 %b) #0 {
53  %alloca = alloca [16 x i32], align 4
54  %ptr0 = getelementptr inbounds [16 x i32], [16 x i32]* %alloca, i32 0, i32 %a
55  %ptr1 = call i32* @get_unknown_pointer()
56  %cmp = icmp eq i32* %ptr0, %ptr1
57  %zext = zext i1 %cmp to i32
58  store volatile i32 %zext, i32 addrspace(1)* %out
59  ret void
60}
61
62declare i32* @get_unknown_pointer() #0
63
64attributes #0 = { nounwind "amdgpu-max-waves-per-eu"="1" }
65