1 ; RUN: llc < %s -mtriple=thumbv7m -mcpu=cortex-m7 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-BP 2 ; RUN: llc < %s -mtriple=thumbv7m -mcpu=cortex-m3 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-NOBP 3 4 declare void @otherfn() 5 6 ; CHECK-LABEL: triangle1: 7 ; CHECK: itt ne 8 ; CHECK: movne 9 ; CHECK: strne 10 define i32 @triangle1(i32 %n, i32* %p) { 11 entry: 12 %tobool = icmp eq i32 %n, 0 13 br i1 %tobool, label %if.end, label %if.then 14 15 if.then: 16 store i32 1, i32* %p, align 4 17 br label %if.end 18 19 if.end: 20 tail call void @otherfn() 21 ret i32 0 22 } 23 24 ; CHECK-LABEL: triangle2: 25 ; CHECK-BP: itttt ne 26 ; CHECK-BP: movne 27 ; CHECK-BP: strne 28 ; CHECK-BP: movne 29 ; CHECK-BP: strne 30 ; CHECK-NOBP: cbz 31 ; CHECK-NOBP: movs 32 ; CHECK-NOBP: str 33 ; CHECK-NOBP: movs 34 ; CHECK-NOBP: str 35 define i32 @triangle2(i32 %n, i32* %p, i32* %q) { 36 entry: 37 %tobool = icmp eq i32 %n, 0 38 br i1 %tobool, label %if.end, label %if.then 39 40 if.then: 41 store i32 1, i32* %p, align 4 42 store i32 2, i32* %q, align 4 43 br label %if.end 44 45 if.end: 46 tail call void @otherfn() 47 ret i32 0 48 } 49 50 ; CHECK-LABEL: triangle3: 51 ; CHECK: cbz 52 ; CHECK: movs 53 ; CHECK: str 54 ; CHECK: movs 55 ; CHECK: str 56 ; CHECK: movs 57 ; CHECK: str 58 define i32 @triangle3(i32 %n, i32* %p, i32* %q, i32* %r) { 59 entry: 60 %tobool = icmp eq i32 %n, 0 61 br i1 %tobool, label %if.end, label %if.then 62 63 if.then: 64 store i32 1, i32* %p, align 4 65 store i32 2, i32* %q, align 4 66 store i32 3, i32* %r, align 4 67 br label %if.end 68 69 if.end: 70 tail call void @otherfn() 71 ret i32 0 72 } 73 74 ; CHECK-LABEL: diamond1: 75 ; CHECK: itee eq 76 ; CHECK: ldreq 77 ; CHECK: strne 78 define i32 @diamond1(i32 %n, i32* %p) { 79 entry: 80 %tobool = icmp eq i32 %n, 0 81 br i1 %tobool, label %if.else, label %if.then 82 83 if.then: 84 store i32 %n, i32* %p, align 4 85 br label %if.end 86 87 if.else: 88 %0 = load i32, i32* %p, align 4 89 br label %if.end 90 91 if.end: 92 %n.addr.0 = phi i32 [ %n, %if.then ], [ %0, %if.else ] 93 tail call void @otherfn() 94 ret i32 %n.addr.0 95 } 96 97 ; CHECK-LABEL: diamond2: 98 ; CHECK-BP: cbz 99 ; CHECK-BP: str 100 ; CHECK-BP: str 101 ; CHECK-BP: b 102 ; CHECK-BP: str 103 ; CHECK-BP: ldr 104 ; CHECK-NOBP: ittee 105 ; CHECK-NOBP: streq 106 ; CHECK-NOBP: ldreq 107 ; CHECK-NOBP: strne 108 ; CHECK-NOBP: strne 109 define i32 @diamond2(i32 %n, i32* %p, i32* %q) { 110 entry: 111 %tobool = icmp eq i32 %n, 0 112 br i1 %tobool, label %if.else, label %if.then 113 114 if.then: 115 store i32 %n, i32* %p, align 4 116 %arrayidx = getelementptr inbounds i32, i32* %p, i32 2 117 store i32 %n, i32* %arrayidx, align 4 118 br label %if.end 119 120 if.else: 121 store i32 %n, i32* %q, align 4 122 %0 = load i32, i32* %p, align 4 123 br label %if.end 124 125 if.end: 126 %n.addr.0 = phi i32 [ %n, %if.then ], [ %0, %if.else ] 127 tail call void @otherfn() 128 ret i32 %n.addr.0 129 } 130 131 ; CHECK-LABEL: diamond3: 132 ; CHECK: cbz 133 ; CHECK: movs 134 ; CHECK: str 135 ; CHECK: b 136 ; CHECK: ldr 137 ; CHECK: ldr 138 ; CHECK: adds 139 define i32 @diamond3(i32 %n, i32* %p, i32* %q) { 140 entry: 141 %tobool = icmp eq i32 %n, 0 142 br i1 %tobool, label %if.else, label %if.then 143 144 if.then: 145 store i32 1, i32* %p, align 4 146 br label %if.end 147 148 if.else: 149 %0 = load i32, i32* %p, align 4 150 %1 = load i32, i32* %q, align 4 151 %add = add nsw i32 %1, %0 152 br label %if.end 153 154 if.end: 155 %n.addr.0 = phi i32 [ %n, %if.then ], [ %add, %if.else ] 156 tail call void @otherfn() 157 ret i32 %n.addr.0 158 } 159