1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc -O2 -mtriple armv7a < %s | FileCheck --check-prefixes=ARM %s 3 4; RUN: llc -O2 -mtriple thumbv6m < %s | FileCheck --check-prefixes=THUMBV6M %s 5; RUN: llc -O2 -mtriple thumbv8m.base < %s | FileCheck --check-prefixes=THUMBV8M-BASE %s 6 7; RUN: llc -O2 -mtriple thumbv7a < %s | FileCheck --check-prefixes=THUMB %s 8; RUN: llc -O2 -mtriple thumbv8m.main < %s | FileCheck --check-prefixes=THUMB %s 9 10define void @fn1(i32 %a, i32 %b, i32 %c) local_unnamed_addr #0 { 11; ARM-LABEL: fn1: 12; ARM: @ %bb.0: @ %entry 13; ARM-NEXT: rsb r2, r2, #0 14; ARM-NEXT: adds r0, r1, r0 15; ARM-NEXT: movw r1, #65535 16; ARM-NEXT: sxth r2, r2 17; ARM-NEXT: adc r0, r2, #0 18; ARM-NEXT: uxth r0, r0 19; ARM-NEXT: cmp r0, r1 20; ARM-NEXT: bxeq lr 21; ARM-NEXT: .LBB0_1: @ %for.cond 22; ARM-NEXT: @ =>This Inner Loop Header: Depth=1 23; ARM-NEXT: b .LBB0_1 24; 25; THUMBV6M-LABEL: fn1: 26; THUMBV6M: @ %bb.0: @ %entry 27; THUMBV6M-NEXT: rsbs r2, r2, #0 28; THUMBV6M-NEXT: sxth r2, r2 29; THUMBV6M-NEXT: movs r3, #0 30; THUMBV6M-NEXT: adds r0, r1, r0 31; THUMBV6M-NEXT: adcs r3, r2 32; THUMBV6M-NEXT: uxth r0, r3 33; THUMBV6M-NEXT: ldr r1, .LCPI0_0 34; THUMBV6M-NEXT: cmp r0, r1 35; THUMBV6M-NEXT: beq .LBB0_2 36; THUMBV6M-NEXT: .LBB0_1: @ %for.cond 37; THUMBV6M-NEXT: @ =>This Inner Loop Header: Depth=1 38; THUMBV6M-NEXT: b .LBB0_1 39; THUMBV6M-NEXT: .LBB0_2: @ %if.end 40; THUMBV6M-NEXT: bx lr 41; THUMBV6M-NEXT: .p2align 2 42; THUMBV6M-NEXT: @ %bb.3: 43; THUMBV6M-NEXT: .LCPI0_0: 44; THUMBV6M-NEXT: .long 65535 @ 0xffff 45; 46; THUMBV8M-BASE-LABEL: fn1: 47; THUMBV8M-BASE: @ %bb.0: @ %entry 48; THUMBV8M-BASE-NEXT: rsbs r2, r2, #0 49; THUMBV8M-BASE-NEXT: sxth r2, r2 50; THUMBV8M-BASE-NEXT: movs r3, #0 51; THUMBV8M-BASE-NEXT: adds r0, r1, r0 52; THUMBV8M-BASE-NEXT: adcs r3, r2 53; THUMBV8M-BASE-NEXT: uxth r0, r3 54; THUMBV8M-BASE-NEXT: movw r1, #65535 55; THUMBV8M-BASE-NEXT: cmp r0, r1 56; THUMBV8M-BASE-NEXT: beq .LBB0_2 57; THUMBV8M-BASE-NEXT: .LBB0_1: @ %for.cond 58; THUMBV8M-BASE-NEXT: @ =>This Inner Loop Header: Depth=1 59; THUMBV8M-BASE-NEXT: b .LBB0_1 60; THUMBV8M-BASE-NEXT: .LBB0_2: @ %if.end 61; THUMBV8M-BASE-NEXT: bx lr 62; 63; THUMB-LABEL: fn1: 64; THUMB: @ %bb.0: @ %entry 65; THUMB-NEXT: rsbs r2, r2, #0 66; THUMB-NEXT: adds r0, r0, r1 67; THUMB-NEXT: movw r1, #65535 68; THUMB-NEXT: sxth r2, r2 69; THUMB-NEXT: adc r0, r2, #0 70; THUMB-NEXT: uxth r0, r0 71; THUMB-NEXT: cmp r0, r1 72; THUMB-NEXT: it eq 73; THUMB-NEXT: bxeq lr 74; THUMB-NEXT: .LBB0_1: @ %for.cond 75; THUMB-NEXT: @ =>This Inner Loop Header: Depth=1 76; THUMB-NEXT: b .LBB0_1 77entry: 78 %add = add i32 %b, %a 79 %cmp = icmp ult i32 %add, %b 80 %conv = zext i1 %cmp to i32 81 %sub = sub i32 1, %c 82 %add1 = add i32 %sub, %conv 83 %conv2 = trunc i32 %add1 to i16 84 %tobool = icmp eq i16 %conv2, 0 85 br i1 %tobool, label %if.end, label %for.cond.preheader 86 87for.cond.preheader: ; preds = %entry 88 br label %for.cond 89 90for.cond: ; preds = %for.cond.preheader, %for.cond 91 br label %for.cond 92 93if.end: ; preds = %entry 94 ret void 95} 96