1 ; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -loop-reduce %s | FileCheck %s
3 ; Test for assert resulting from inconsistent isLegalAddressingMode
4 ; answers when the address space was dropped from the query.
6 target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5"
8 %0 = type { i32, double, i32, float }
10 ; CHECK-LABEL: @lsr_crash_preserve_addrspace_unknown_type(
11 ; CHECK: %scevgep1 = getelementptr i8, ptr addrspace(3) %tmp, i32 8
12 ; CHECK: load double, ptr addrspace(3) %scevgep1
14 ; CHECK: %scevgep = getelementptr i8, ptr addrspace(3) %tmp, i32 16
15 ; CHECK: %tmp14 = load i32, ptr addrspace(3) %scevgep
16 define amdgpu_kernel void @lsr_crash_preserve_addrspace_unknown_type() #0 {
20 bb1: ; preds = %bb17, %bb
21 %tmp = phi ptr addrspace(3) [ undef, %bb ], [ %tmp18, %bb17 ]
22 %tmp2 = getelementptr inbounds %0, ptr addrspace(3) %tmp, i64 0, i32 1
23 %tmp3 = load double, ptr addrspace(3) %tmp2, align 8
27 br i1 undef, label %bb8, label %bb5
33 %tmp10 = load i32, ptr addrspace(3) %tmp, align 4
34 %tmp11 = icmp eq i32 0, %tmp10
35 br i1 %tmp11, label %bb12, label %bb17
38 %tmp13 = getelementptr inbounds %0, ptr addrspace(3) %tmp, i64 0, i32 2
39 %tmp14 = load i32, ptr addrspace(3) %tmp13, align 4
40 %tmp15 = icmp eq i32 0, %tmp14
41 br i1 %tmp15, label %bb16, label %bb17
46 bb17: ; preds = %bb12, %bb8
47 %tmp18 = getelementptr inbounds %0, ptr addrspace(3) %tmp, i64 2
51 ; CHECK-LABEL: @lsr_crash_preserve_addrspace_unknown_type2(
52 ; CHECK: %idx = getelementptr inbounds i8, ptr addrspace(5) %array, i32 %j
53 ; CHECK: %idx1 = getelementptr inbounds i8, ptr addrspace(3) %array2, i32 %j
54 ; CHECK: %t = getelementptr inbounds i8, ptr addrspace(5) %array, i32 %j
55 ; CHECK: %n8 = load i8, ptr addrspace(5) %t, align 4
56 ; CHECK: call void @llvm.memcpy.p5.p3.i64(ptr addrspace(5) %idx, ptr addrspace(3) %idx1, i64 42, i1 false)
57 ; CHECK: call void @llvm.memmove.p5.p3.i64(ptr addrspace(5) %idx, ptr addrspace(3) %idx1, i64 42, i1 false)
58 ; CHECK: call void @llvm.memset.p5.i64(ptr addrspace(5) %idx, i8 42, i64 42, i1 false)
59 define void @lsr_crash_preserve_addrspace_unknown_type2(ptr addrspace(5) %array, ptr addrspace(3) %array2) {
63 for.body: ; preds = %entry, %for.inc
64 %j = phi i32 [ %add, %for.inc ], [ 0, %entry ]
65 %idx = getelementptr inbounds i8, ptr addrspace(5) %array, i32 %j
66 %idx1 = getelementptr inbounds i8, ptr addrspace(3) %array2, i32 %j
67 %t = getelementptr inbounds i8, ptr addrspace(5) %array, i32 %j
68 %n8 = load i8, ptr addrspace(5) %t, align 4
69 %n7 = getelementptr inbounds i8, ptr addrspace(5) %t, i32 42
70 %n9 = load i8, ptr addrspace(5) %n7, align 4
71 %cmp = icmp sgt i32 %j, 42
72 %add = add nuw nsw i32 %j, 1
73 br i1 %cmp, label %if.then17, label %for.inc
75 if.then17: ; preds = %for.body
76 call void @llvm.memcpy.p5.p5.i64(ptr addrspace(5) %idx, ptr addrspace(3) %idx1, i64 42, i1 false)
77 call void @llvm.memmove.p5.p5.i64(ptr addrspace(5) %idx, ptr addrspace(3) %idx1, i64 42, i1 false)
78 call void @llvm.memset.p5.i64(ptr addrspace(5) %idx, i8 42, i64 42, i1 false)
81 for.inc: ; preds = %for.body, %if.then17
82 %exitcond = icmp eq i1 %cmp, 1
83 br i1 %exitcond, label %end, label %for.body
85 end: ; preds = %for.inc
89 declare void @llvm.memcpy.p5.p5.i64(ptr addrspace(5), ptr addrspace(3), i64, i1)
90 declare void @llvm.memmove.p5.p5.i64(ptr addrspace(5), ptr addrspace(3), i64, i1)
91 declare void @llvm.memset.p5.i64(ptr addrspace(5), i8, i64, i1)
93 attributes #0 = { nounwind }
94 attributes #1 = { nounwind readnone }