1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc -mtriple=thumbv6m-eabi -asm-verbose=false %s -o - | FileCheck %s 3 4define void @test8(i8* %a) { 5; CHECK-LABEL: test8: 6; CHECK: ldrb r1, [r0] 7; CHECK-NEXT: mvns r1, r1 8; CHECK-NEXT: strb r1, [r0] 9; CHECK-NEXT: bx lr 10 %x = load i8, i8* %a 11 %xn = xor i8 %x, -1 12 store i8 %xn, i8* %a 13 ret void 14} 15 16define void @test8_2(i8* %a, i8* %b) { 17; CHECK-LABEL: test8_2: 18; CHECK: ldrb r2, [r1] 19; CHECK-NEXT: ldrb r3, [r0] 20; CHECK-NEXT: mvns r3, r3 21; CHECK-NEXT: strb r3, [r0] 22; CHECK-NEXT: mvns r0, r2 23; CHECK-NEXT: strb r0, [r1] 24; CHECK-NEXT: bx lr 25 %x = load i8, i8* %a 26 %y = load i8, i8* %b 27 %xn = xor i8 %x, -1 28 %yn = xor i8 %y, -1 29 store i8 %xn, i8* %a 30 store i8 %yn, i8* %b 31 ret void 32} 33 34define void @loop8(i8* %a) { 35; CHECK-LABEL: loop8: 36; CHECK: movs r1, #0 37; CHECK-NEXT: .LBB2_1: 38; CHECK-NEXT: ldrb r2, [r0, r1] 39; CHECK-NEXT: mvns r2, r2 40; CHECK-NEXT: strb r2, [r0, r1] 41; CHECK-NEXT: adds r1, r1, #1 42; CHECK-NEXT: cmp r1, #10 43; CHECK-NEXT: bne .LBB2_1 44; CHECK-NEXT: bx lr 45entry: 46 br label %for.body 47 48for.body: 49 %i = phi i32 [ 0, %entry ], [ %inc, %for.body ] 50 %arrayidx = getelementptr inbounds i8, i8* %a, i32 %i 51 %x = load i8, i8* %arrayidx 52 %xn = xor i8 %x, -1 53 store i8 %xn, i8* %arrayidx 54 %inc = add nuw nsw i32 %i, 1 55 %exitcond = icmp eq i32 %inc, 10 56 br i1 %exitcond, label %for.cond.cleanup, label %for.body 57 58for.cond.cleanup: 59 ret void 60} 61 62define void @loop8_2(i8* %a, i8* %b) { 63; CHECK-LABEL: loop8_2: 64; CHECK: .save {r4, lr} 65; CHECK-NEXT: push {r4, lr} 66; CHECK-NEXT: movs r2, #0 67; CHECK-NEXT: .LBB3_1: 68; CHECK-NEXT: ldrb r3, [r1, r2] 69; CHECK-NEXT: ldrb r4, [r0, r2] 70; CHECK-NEXT: mvns r4, r4 71; CHECK-NEXT: strb r4, [r0, r2] 72; CHECK-NEXT: mvns r3, r3 73; CHECK-NEXT: strb r3, [r1, r2] 74; CHECK-NEXT: adds r2, r2, #1 75; CHECK-NEXT: cmp r2, #10 76; CHECK-NEXT: bne .LBB3_1 77; CHECK-NEXT: pop {r4, pc} 78entry: 79 br label %for.body 80 81for.body: 82 %i = phi i32 [ 0, %entry ], [ %inc, %for.body ] 83 %arrayidx = getelementptr inbounds i8, i8* %a, i32 %i 84 %arrayidx2 = getelementptr inbounds i8, i8* %b, i32 %i 85 %x = load i8, i8* %arrayidx 86 %y = load i8, i8* %arrayidx2 87 %xn = xor i8 %x, -1 88 %yn = xor i8 %y, -1 89 store i8 %xn, i8* %arrayidx 90 store i8 %yn, i8* %arrayidx2 91 %inc = add nuw nsw i32 %i, 1 92 %exitcond = icmp eq i32 %inc, 10 93 br i1 %exitcond, label %for.cond.cleanup, label %for.body 94 95for.cond.cleanup: 96 ret void 97} 98 99define void @test32(i32* %a) { 100; CHECK-LABEL: test32: 101; CHECK: ldr r1, [r0] 102; CHECK-NEXT: mvns r1, r1 103; CHECK-NEXT: str r1, [r0] 104; CHECK-NEXT: bx lr 105 %x = load i32, i32* %a 106 %xn = xor i32 %x, -1 107 store i32 %xn, i32* %a 108 ret void 109} 110 111define void @test32_2(i32* %a, i32* %b) { 112; CHECK-LABEL: test32_2: 113; CHECK: ldr r2, [r1] 114; CHECK-NEXT: ldr r3, [r0] 115; CHECK-NEXT: mvns r3, r3 116; CHECK-NEXT: str r3, [r0] 117; CHECK-NEXT: mvns r0, r2 118; CHECK-NEXT: str r0, [r1] 119; CHECK-NEXT: bx lr 120 %x = load i32, i32* %a 121 %y = load i32, i32* %b 122 %xn = xor i32 %x, -1 123 %yn = xor i32 %y, -1 124 store i32 %xn, i32* %a 125 store i32 %yn, i32* %b 126 ret void 127} 128 129define void @loop32(i32* %a) { 130; CHECK-LABEL: loop32: 131; CHECK: movs r1, #0 132; CHECK-NEXT: .LBB6_1: 133; CHECK-NEXT: ldr r2, [r0, r1] 134; CHECK-NEXT: mvns r2, r2 135; CHECK-NEXT: str r2, [r0, r1] 136; CHECK-NEXT: adds r1, r1, #4 137; CHECK-NEXT: cmp r1, #40 138; CHECK-NEXT: bne .LBB6_1 139; CHECK-NEXT: bx lr 140entry: 141 br label %for.body 142 143for.body: 144 %i = phi i32 [ 0, %entry ], [ %inc, %for.body ] 145 %arrayidx = getelementptr inbounds i32, i32* %a, i32 %i 146 %x = load i32, i32* %arrayidx 147 %xn = xor i32 %x, -1 148 store i32 %xn, i32* %arrayidx 149 %inc = add nuw nsw i32 %i, 1 150 %exitcond = icmp eq i32 %inc, 10 151 br i1 %exitcond, label %for.cond.cleanup, label %for.body 152 153for.cond.cleanup: 154 ret void 155} 156 157define void @loop32_2(i32* %a, i32* %b) { 158; CHECK-LABEL: loop32_2: 159; CHECK: .save {r4, lr} 160; CHECK-NEXT: push {r4, lr} 161; CHECK-NEXT: movs r2, #0 162; CHECK-NEXT: .LBB7_1: 163; CHECK-NEXT: ldr r3, [r1, r2] 164; CHECK-NEXT: ldr r4, [r0, r2] 165; CHECK-NEXT: mvns r4, r4 166; CHECK-NEXT: str r4, [r0, r2] 167; CHECK-NEXT: mvns r3, r3 168; CHECK-NEXT: str r3, [r1, r2] 169; CHECK-NEXT: adds r2, r2, #4 170; CHECK-NEXT: cmp r2, #40 171; CHECK-NEXT: bne .LBB7_1 172; CHECK-NEXT: pop {r4, pc} 173entry: 174 br label %for.body 175 176for.body: 177 %i = phi i32 [ 0, %entry ], [ %inc, %for.body ] 178 %arrayidx = getelementptr inbounds i32, i32* %a, i32 %i 179 %arrayidx2 = getelementptr inbounds i32, i32* %b, i32 %i 180 %x = load i32, i32* %arrayidx 181 %y = load i32, i32* %arrayidx2 182 %xn = xor i32 %x, -1 183 %yn = xor i32 %y, -1 184 store i32 %xn, i32* %arrayidx 185 store i32 %yn, i32* %arrayidx2 186 %inc = add nuw nsw i32 %i, 1 187 %exitcond = icmp eq i32 %inc, 10 188 br i1 %exitcond, label %for.cond.cleanup, label %for.body 189 190for.cond.cleanup: 191 ret void 192} 193 194 195define void @test128(i128* %a) { 196; CHECK-LABEL: test128: 197; CHECK: ldr r1, [r0, #4] 198; CHECK-NEXT: ldr r2, .LCPI8_0 199; CHECK-NEXT: eors r2, r1 200; CHECK-NEXT: str r2, [r0, #4] 201; CHECK-NEXT: ldr r1, [r0] 202; CHECK-NEXT: ldr r2, .LCPI8_1 203; CHECK-NEXT: eors r2, r1 204; CHECK-NEXT: str r2, [r0] 205; CHECK-NEXT: ldr r1, [r0, #8] 206; CHECK-NEXT: ldr r2, .LCPI8_2 207; CHECK-NEXT: eors r2, r1 208; CHECK-NEXT: str r2, [r0, #8] 209; CHECK-NEXT: bx lr 210; CHECK-NEXT: .p2align 2 211; CHECK-NEXT: .LCPI8_0: 212; CHECK-NEXT: .long 4075008415 213; CHECK-NEXT: .LCPI8_1: 214; CHECK-NEXT: .long 2080661269 215; CHECK-NEXT: .LCPI8_2: 216; CHECK-NEXT: .long 6692605 217 %x = load i128, i128* %a 218 %xn = xor i128 %x, 123456789123456789123456789 219 store i128 %xn, i128* %a 220 ret void 221} 222 223