1; RUN: llc -mtriple=aarch64-linux-gnu -verify-machineinstrs -o - %s | FileCheck %s 2 3%struct_type = type { [10000 x i32], i32, i32 } 4 5define void @test1(%struct_type** %s, i32 %n) { 6; CHECK-LABEL: test1 7entry: 8 %struct = load %struct_type*, %struct_type** %s 9 br label %while_cond 10 11while_cond: 12 %phi = phi i32 [ 0, %entry ], [ %i, %while_body ] 13; CHECK: mov w{{[0-9]+}}, #40000 14; CHECK-NOT: mov w{{[0-9]+}}, #40004 15 %gep0 = getelementptr %struct_type, %struct_type* %struct, i64 0, i32 1 16 %gep1 = getelementptr %struct_type, %struct_type* %struct, i64 0, i32 2 17 %cmp = icmp slt i32 %phi, %n 18 br i1 %cmp, label %while_body, label %while_end 19 20while_body: 21; CHECK: str w{{[0-9]+}}, [x{{[0-9]+}}, #4] 22 %i = add i32 %phi, 1 23 store i32 %i, i32* %gep0 24 store i32 %phi, i32* %gep1 25 br label %while_cond 26 27while_end: 28 ret void 29} 30 31define void @test2(%struct_type* %struct, i32 %n) { 32; CHECK-LABEL: test2 33entry: 34 %cmp = icmp eq %struct_type* %struct, null 35 br i1 %cmp, label %while_end, label %while_cond 36 37while_cond: 38 %phi = phi i32 [ 0, %entry ], [ %i, %while_body ] 39; CHECK: mov w{{[0-9]+}}, #40000 40; CHECK-NOT: mov w{{[0-9]+}}, #40004 41 %gep0 = getelementptr %struct_type, %struct_type* %struct, i64 0, i32 1 42 %gep1 = getelementptr %struct_type, %struct_type* %struct, i64 0, i32 2 43 %cmp1 = icmp slt i32 %phi, %n 44 br i1 %cmp1, label %while_body, label %while_end 45 46while_body: 47; CHECK: str w{{[0-9]+}}, [x{{[0-9]+}}, #4] 48 %i = add i32 %phi, 1 49 store i32 %i, i32* %gep0 50 store i32 %phi, i32* %gep1 51 br label %while_cond 52 53while_end: 54 ret void 55} 56 57define void @test3(%struct_type* %s1, %struct_type* %s2, i1 %cond, i32 %n) { 58; CHECK-LABEL: test3 59entry: 60 br i1 %cond, label %if_true, label %if_end 61 62if_true: 63 br label %if_end 64 65if_end: 66 %struct = phi %struct_type* [ %s1, %entry ], [ %s2, %if_true ] 67 %cmp = icmp eq %struct_type* %struct, null 68 br i1 %cmp, label %while_end, label %while_cond 69 70while_cond: 71 %phi = phi i32 [ 0, %if_end ], [ %i, %while_body ] 72; CHECK: mov w{{[0-9]+}}, #40000 73; CHECK-NOT: mov w{{[0-9]+}}, #40004 74 %gep0 = getelementptr %struct_type, %struct_type* %struct, i64 0, i32 1 75 %gep1 = getelementptr %struct_type, %struct_type* %struct, i64 0, i32 2 76 %cmp1 = icmp slt i32 %phi, %n 77 br i1 %cmp1, label %while_body, label %while_end 78 79while_body: 80; CHECK: str w{{[0-9]+}}, [x{{[0-9]+}}, #4] 81 %i = add i32 %phi, 1 82 store i32 %i, i32* %gep0 83 store i32 %phi, i32* %gep1 84 br label %while_cond 85 86while_end: 87 ret void 88} 89 90declare %struct_type* @foo() 91declare void @foo2() 92 93define void @test4(i32 %n) personality i32 (...)* @__FrameHandler { 94; CHECK-LABEL: test4 95entry: 96 br label %while_cond 97 98while_cond: 99 %phi = phi i32 [ 0, %entry ], [ %i, %while_body ] 100 %struct = invoke %struct_type* @foo() to label %while_cond_x unwind label %cleanup 101 102while_cond_x: 103; CHECK: mov w{{[0-9]+}}, #40000 104; CHECK-NOT: mov w{{[0-9]+}}, #40004 105 %gep0 = getelementptr %struct_type, %struct_type* %struct, i64 0, i32 1 106 %gep1 = getelementptr %struct_type, %struct_type* %struct, i64 0, i32 2 107 store i32 0, i32* %gep0 108 %cmp = icmp slt i32 %phi, %n 109 br i1 %cmp, label %while_body, label %while_end 110 111while_body: 112; CHECK: str w{{[0-9]+}}, [x{{[0-9]+}}, #4] 113 %i = add i32 %phi, 1 114 store i32 %i, i32* %gep0 115 store i32 %phi, i32* %gep1 116 br label %while_cond 117 118while_end: 119 ret void 120 121cleanup: 122 %x10 = landingpad { i8*, i32 } 123 cleanup 124 call void @foo2() 125 resume { i8*, i32 } %x10 126} 127 128declare i32 @__FrameHandler(...) 129 130define void @test5([65536 x i32]** %s, i32 %n) { 131; CHECK-LABEL: test5 132entry: 133 %struct = load [65536 x i32]*, [65536 x i32]** %s 134 br label %while_cond 135 136while_cond: 137 %phi = phi i32 [ 0, %entry ], [ %i, %while_body ] 138; CHECK: mov w{{[0-9]+}}, #14464 139; CHECK-NOT: mov w{{[0-9]+}}, #14468 140 %gep0 = getelementptr [65536 x i32], [65536 x i32]* %struct, i64 0, i32 20000 141 %gep1 = getelementptr [65536 x i32], [65536 x i32]* %struct, i64 0, i32 20001 142 %cmp = icmp slt i32 %phi, %n 143 br i1 %cmp, label %while_body, label %while_end 144 145while_body: 146; CHECK: str w{{[0-9]+}}, [x{{[0-9]+}}, #4] 147 %i = add i32 %phi, 1 148 store i32 %i, i32* %gep0 149 store i32 %phi, i32* %gep1 150 br label %while_cond 151 152while_end: 153 ret void 154} 155 156declare i8* @llvm.strip.invariant.group.p0i8(i8*) 157 158define void @test_invariant_group(i32) { 159; CHECK-LABEL: test_invariant_group 160 br i1 undef, label %8, label %7 161 162; <label>:2: ; preds = %8, %2 163 br i1 undef, label %2, label %7 164 165; <label>:3: ; preds = %8 166 %4 = getelementptr inbounds i8, i8* %9, i32 40000 167 %5 = bitcast i8* %4 to i64* 168 br i1 undef, label %7, label %6 169 170; <label>:6: ; preds = %3 171 store i64 1, i64* %5, align 8 172 br label %7 173 174; <label>:7: ; preds = %6, %3, %2, %1 175 ret void 176 177; <label>:8: ; preds = %1 178 %9 = call i8* @llvm.strip.invariant.group.p0i8(i8* nonnull undef) 179 %10 = icmp eq i32 %0, 0 180 br i1 %10, label %3, label %2 181} 182 183