|
| 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: ite 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: itte |
| 99 | +; CHECK-BP: streq |
| 100 | +; CHECK-BP: ldreq |
| 101 | +; CHECK-BP: strne |
| 102 | +; CHECK-NOBP: cbz |
| 103 | +; CHECK-NOBP: str |
| 104 | +; CHECK-NOBP: b |
| 105 | +; CHECK-NOBP: str |
| 106 | +; CHECK-NOBP: ldr |
| 107 | +define i32 @diamond2(i32 %n, i32 %m, i32* %p, i32* %q) { |
| 108 | +entry: |
| 109 | + %tobool = icmp eq i32 %n, 0 |
| 110 | + br i1 %tobool, label %if.else, label %if.then |
| 111 | + |
| 112 | +if.then: |
| 113 | + store i32 %n, i32* %p, align 4 |
| 114 | + br label %if.end |
| 115 | + |
| 116 | +if.else: |
| 117 | + store i32 %m, i32* %q, align 4 |
| 118 | + %0 = load i32, i32* %p, align 4 |
| 119 | + br label %if.end |
| 120 | + |
| 121 | +if.end: |
| 122 | + %n.addr.0 = phi i32 [ %n, %if.then ], [ %0, %if.else ] |
| 123 | + tail call void @otherfn() |
| 124 | + ret i32 %n.addr.0 |
| 125 | +} |
| 126 | + |
| 127 | +; CHECK-LABEL: diamond3: |
| 128 | +; CHECK: cbz |
| 129 | +; CHECK: movs |
| 130 | +; CHECK: str |
| 131 | +; CHECK: b |
| 132 | +; CHECK: ldr |
| 133 | +; CHECK: ldr |
| 134 | +; CHECK: adds |
| 135 | +define i32 @diamond3(i32 %n, i32* %p, i32* %q) { |
| 136 | +entry: |
| 137 | + %tobool = icmp eq i32 %n, 0 |
| 138 | + br i1 %tobool, label %if.else, label %if.then |
| 139 | + |
| 140 | +if.then: |
| 141 | + store i32 1, i32* %p, align 4 |
| 142 | + br label %if.end |
| 143 | + |
| 144 | +if.else: |
| 145 | + %0 = load i32, i32* %p, align 4 |
| 146 | + %1 = load i32, i32* %q, align 4 |
| 147 | + %add = add nsw i32 %1, %0 |
| 148 | + br label %if.end |
| 149 | + |
| 150 | +if.end: |
| 151 | + %n.addr.0 = phi i32 [ %n, %if.then ], [ %add, %if.else ] |
| 152 | + tail call void @otherfn() |
| 153 | + ret i32 %n.addr.0 |
| 154 | +} |
0 commit comments