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 6 target 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 ], [ %{{[0-9]+}}, %entry ] 12 ; CHECK: %lsr.iv.next = add i32 %lsr.iv, -1 13 ; CHECK: %lsr.iv.next2 = add i32 %lsr.iv1, -2 14 ; CHECK: br i1 15 16 ; CHECK: bb: 17 ; CHECK: inttoptr i32 %lsr.iv.next2 to i8 addrspace(3)* 18 ; CHECK: %c1 = icmp ne i8 addrspace(3)* 19 define void @local_cmp_user(i32 %arg0) nounwind { 20 entry: 21 br label %bb11 22 23 bb11: 24 %i = phi i32 [ 0, %entry ], [ %i.next, %bb ] 25 %ii = shl i32 %i, 1 26 %c0 = icmp eq i32 %i, %arg0 27 br i1 %c0, label %bb13, label %bb 28 29 bb: 30 %t = load i8 addrspace(3)*, i8 addrspace(3)* addrspace(3)* undef 31 %p = getelementptr i8, i8 addrspace(3)* %t, i32 %ii 32 %c1 = icmp ne i8 addrspace(3)* %p, null 33 %i.next = add i32 %i, 1 34 br i1 %c1, label %bb11, label %bb13 35 36 bb13: 37 unreachable 38 } 39 40 ; CHECK-LABEL: @global_cmp_user( 41 ; CHECK: %lsr.iv1 = phi i64 42 ; CHECK: %lsr.iv = phi i64 43 ; CHECK: %lsr.iv.next = add i64 %lsr.iv, -1 44 ; CHECK: %lsr.iv.next2 = add i64 %lsr.iv1, -2 45 ; CHECK: br i1 46 47 ; CHECK: bb: 48 ; CHECK: inttoptr i64 %lsr.iv.next2 to i8 addrspace(1)* 49 ; CHECK: icmp ne i8 addrspace(1)* %t 50 define void @global_cmp_user(i64 %arg0) nounwind { 51 entry: 52 br label %bb11 53 54 bb11: 55 %i = phi i64 [ 0, %entry ], [ %i.next, %bb ] 56 %ii = shl i64 %i, 1 57 %c0 = icmp eq i64 %i, %arg0 58 br i1 %c0, label %bb13, label %bb 59 60 bb: 61 %t = load i8 addrspace(1)*, i8 addrspace(1)* addrspace(1)* undef 62 %p = getelementptr i8, i8 addrspace(1)* %t, i64 %ii 63 %c1 = icmp ne i8 addrspace(1)* %p, null 64 %i.next = add i64 %i, 1 65 br i1 %c1, label %bb11, label %bb13 66 67 bb13: 68 unreachable 69 } 70 71 ; CHECK-LABEL: @global_gep_user( 72 ; CHECK: %lsr.iv1 = phi i32 [ %lsr.iv.next2, %bb ], [ 0, %entry ] 73 ; CHECK: %lsr.iv = phi i32 [ %lsr.iv.next, %bb ], [ %{{[0-9]+}}, %entry ] 74 ; CHECK: %lsr.iv.next = add i32 %lsr.iv, -1 75 ; CHECK: %lsr.iv.next2 = add i32 %lsr.iv1, 2 76 ; CHECK: br i1 77 78 ; CHECK: bb: 79 ; CHECK: %idxprom = sext i32 %lsr.iv1 to i64 80 ; CHECK: getelementptr i8, i8 addrspace(1)* %t, i64 %idxprom 81 define void @global_gep_user(i32 %arg0) nounwind { 82 entry: 83 br label %bb11 84 85 bb11: 86 %i = phi i32 [ 0, %entry ], [ %i.next, %bb ] 87 %ii = shl i32 %i, 1 88 %c0 = icmp eq i32 %i, %arg0 89 br i1 %c0, label %bb13, label %bb 90 91 bb: 92 %t = load i8 addrspace(1)*, i8 addrspace(1)* addrspace(1)* undef 93 %p = getelementptr i8, i8 addrspace(1)* %t, i32 %ii 94 %c1 = icmp ne i8 addrspace(1)* %p, null 95 %i.next = add i32 %i, 1 96 br i1 %c1, label %bb11, label %bb13 97 98 bb13: 99 unreachable 100 } 101 102 ; CHECK-LABEL: @global_sext_scale_user( 103 ; CHECK: %lsr.iv1 = phi i32 [ %lsr.iv.next2, %bb ], [ 0, %entry ] 104 ; CHECK: %lsr.iv = phi i32 [ %lsr.iv.next, %bb ], [ %{{[0-9]+}}, %entry ] 105 ; CHECK: %lsr.iv.next = add i32 %lsr.iv, -1 106 ; CHECK: %lsr.iv.next2 = add i32 %lsr.iv1, 2 107 ; CHECK: br i1 108 109 ; CHECK: bb 110 ; CHECK: %p = getelementptr i8, i8 addrspace(1)* %t, i64 %ii.ext 111 define void @global_sext_scale_user(i32 %arg0) nounwind { 112 entry: 113 br label %bb11 114 115 bb11: 116 %i = phi i32 [ 0, %entry ], [ %i.next, %bb ] 117 %ii = shl i32 %i, 1 118 %ii.ext = sext i32 %ii to i64 119 %c0 = icmp eq i32 %i, %arg0 120 br i1 %c0, label %bb13, label %bb 121 122 bb: 123 %t = load i8 addrspace(1)*, i8 addrspace(1)* addrspace(1)* undef 124 %p = getelementptr i8, i8 addrspace(1)* %t, i64 %ii.ext 125 %c1 = icmp ne i8 addrspace(1)* %p, null 126 %i.next = add i32 %i, 1 127 br i1 %c1, label %bb11, label %bb13 128 129 bb13: 130 unreachable 131 } 132