1; RUN: llc -march=amdgcn -mcpu=bonaire -print-lsr-output < %s 2>&1 | FileCheck %s
2
3; Test various conditions where OptimizeLoopTermCond doesn't look at a
4; memory instruction use and fails to find the address space.
5
6target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-p24:64:64-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"
7
8; CHECK-LABEL: @local_cmp_user(
9; CHECK: bb11:
10; CHECK: %lsr.iv1 = phi i32 [ %lsr.iv.next2, %bb ], [ -2, %entry ]
11; CHECK: %lsr.iv = phi i32 [ %lsr.iv.next, %bb ], [ undef, %entry ]
12
13; CHECK: bb:
14; CHECK: %lsr.iv.next = add i32 %lsr.iv, -1
15; CHECK: %lsr.iv.next2 = add i32 %lsr.iv1, 2
16; CHECK: %scevgep = getelementptr i8, i8 addrspace(3)* %t, i32 %lsr.iv.next2
17; CHECK: %c1 = icmp ult i8 addrspace(3)* %scevgep, undef
18define void @local_cmp_user() nounwind {
19entry:
20  br label %bb11
21
22bb11:
23  %i = phi i32 [ 0, %entry ], [ %i.next, %bb ]
24  %ii = shl i32 %i, 1
25  %c0 = icmp eq i32 %i, undef
26  br i1 %c0, label %bb13, label %bb
27
28bb:
29  %t = load i8 addrspace(3)*, i8 addrspace(3)* addrspace(3)* undef
30  %p = getelementptr i8, i8 addrspace(3)* %t, i32 %ii
31  %c1 = icmp ult i8 addrspace(3)* %p, undef
32  %i.next = add i32 %i, 1
33  br i1 %c1, label %bb11, label %bb13
34
35bb13:
36  unreachable
37}
38
39; CHECK-LABEL: @global_cmp_user(
40; CHECK: %lsr.iv.next = add i64 %lsr.iv, -1
41; CHECK: %lsr.iv.next2 = add i64 %lsr.iv1, 2
42; CHECK: %scevgep = getelementptr i8, i8 addrspace(1)* %t, i64 %lsr.iv.next2
43define void @global_cmp_user() nounwind {
44entry:
45  br label %bb11
46
47bb11:
48  %i = phi i64 [ 0, %entry ], [ %i.next, %bb ]
49  %ii = shl i64 %i, 1
50  %c0 = icmp eq i64 %i, undef
51  br i1 %c0, label %bb13, label %bb
52
53bb:
54  %t = load i8 addrspace(1)*, i8 addrspace(1)* addrspace(1)* undef
55  %p = getelementptr i8, i8 addrspace(1)* %t, i64 %ii
56  %c1 = icmp ult i8 addrspace(1)* %p, undef
57  %i.next = add i64 %i, 1
58  br i1 %c1, label %bb11, label %bb13
59
60bb13:
61  unreachable
62}
63
64; CHECK-LABEL: @global_gep_user(
65; CHECK: %p = getelementptr i8, i8 addrspace(1)* %t, i32 %lsr.iv1
66; CHECK: %lsr.iv.next = add i32 %lsr.iv, -1
67; CHECK: %lsr.iv.next2 = add i32 %lsr.iv1, 2
68define void @global_gep_user() nounwind {
69entry:
70  br label %bb11
71
72bb11:
73  %i = phi i32 [ 0, %entry ], [ %i.next, %bb ]
74  %ii = shl i32 %i, 1
75  %c0 = icmp eq i32 %i, undef
76  br i1 %c0, label %bb13, label %bb
77
78bb:
79  %t = load i8 addrspace(1)*, i8 addrspace(1)* addrspace(1)* undef
80  %p = getelementptr i8, i8 addrspace(1)* %t, i32 %ii
81  %c1 = icmp ult i8 addrspace(1)* %p, undef
82  %i.next = add i32 %i, 1
83  br i1 %c1, label %bb11, label %bb13
84
85bb13:
86  unreachable
87}
88
89; CHECK-LABEL: @global_sext_scale_user(
90; CHECK: %p = getelementptr i8, i8 addrspace(1)* %t, i64 %ii.ext
91; CHECK: %lsr.iv.next = add i32 %lsr.iv, -1
92; CHECK: %lsr.iv.next2 = add i32 %lsr.iv1, 2
93define void @global_sext_scale_user() nounwind {
94entry:
95  br label %bb11
96
97bb11:
98  %i = phi i32 [ 0, %entry ], [ %i.next, %bb ]
99  %ii = shl i32 %i, 1
100  %ii.ext = sext i32 %ii to i64
101  %c0 = icmp eq i32 %i, undef
102  br i1 %c0, label %bb13, label %bb
103
104bb:
105  %t = load i8 addrspace(1)*, i8 addrspace(1)* addrspace(1)* undef
106  %p = getelementptr i8, i8 addrspace(1)* %t, i64 %ii.ext
107  %c1 = icmp ult i8 addrspace(1)* %p, undef
108  %i.next = add i32 %i, 1
109  br i1 %c1, label %bb11, label %bb13
110
111bb13:
112  unreachable
113}
114