Home | History | Annotate | Download | only in ARM
      1 ; RUN: llc < %s -mtriple=thumbv7-apple-ios -mcpu=cortex-a8 | FileCheck %s
      2 ; rdar://13782395
      3 
      4 define i32 @t1(i32 %a, i32 %b, i8** %retaddr) {
      5 ; CHECK-LABEL: t1:
      6 ; CHECK: Block address taken
      7 ; CHECK-NOT: Address of block that was removed by CodeGen
      8   store i8* blockaddress(@t1, %cond_true), i8** %retaddr
      9   %tmp2 = icmp eq i32 %a, 0
     10   br i1 %tmp2, label %cond_false, label %cond_true
     11 
     12 cond_true:
     13   %tmp5 = add i32 %b, 1
     14   ret i32 %tmp5
     15 
     16 cond_false:
     17   %tmp7 = add i32 %b, -1
     18   ret i32 %tmp7
     19 }
     20 
     21 define i32 @t2(i32 %a, i32 %b, i32 %c, i32 %d, i8** %retaddr) {
     22 ; CHECK-LABEL: t2:
     23 ; CHECK: Block address taken
     24 ; CHECK: %cond_true
     25 ; CHECK: add
     26 ; CHECK: bx lr
     27   store i8* blockaddress(@t2, %cond_true), i8** %retaddr
     28   %tmp2 = icmp sgt i32 %c, 10
     29   %tmp5 = icmp slt i32 %d, 4
     30   %tmp8 = and i1 %tmp5, %tmp2
     31   %tmp13 = add i32 %b, %a
     32   br i1 %tmp8, label %cond_true, label %UnifiedReturnBlock
     33 
     34 cond_true:
     35   %tmp15 = add i32 %tmp13, %c
     36   %tmp1821 = sub i32 %tmp15, %d
     37   ret i32 %tmp1821
     38 
     39 UnifiedReturnBlock:
     40   ret i32 %tmp13
     41 }
     42 
     43 define hidden fastcc void @t3(i8** %retaddr) {
     44 ; CHECK-LABEL: t3:
     45 ; CHECK: Block address taken
     46 ; CHECK-NOT: Address of block that was removed by CodeGen
     47 bb:
     48   store i8* blockaddress(@t3, %KBBlockZero_return_1), i8** %retaddr
     49   br i1 undef, label %bb77, label %bb7.i
     50 
     51 bb7.i:                                            ; preds = %bb35
     52   br label %bb2.i
     53 
     54 KBBlockZero_return_1:                             ; preds = %KBBlockZero.exit
     55   unreachable
     56 
     57 KBBlockZero_return_0:                             ; preds = %KBBlockZero.exit
     58   unreachable
     59 
     60 bb77:                                             ; preds = %bb26, %bb12, %bb
     61   ret void
     62 
     63 bb2.i:                                            ; preds = %bb6.i350, %bb7.i
     64   br i1 undef, label %bb6.i350, label %KBBlockZero.exit
     65 
     66 bb6.i350:                                         ; preds = %bb2.i
     67   br label %bb2.i
     68 
     69 KBBlockZero.exit:                                 ; preds = %bb2.i
     70   indirectbr i8* undef, [label %KBBlockZero_return_1, label %KBBlockZero_return_0]
     71 }
     72 
     73 
     74 ; If-converter was checking for the wrong predicate subsumes pattern when doing
     75 ; nested predicates.
     76 ; E.g., Let A be a basic block that flows conditionally into B and B be a
     77 ; predicated block.
     78 ; B can be predicated with A.BrToBPredicate into A iff B.Predicate is less
     79 ; "permissive" than A.BrToBPredicate, i.e., iff A.BrToBPredicate subsumes
     80 ; B.Predicate. 
     81 ; <rdar://problem/14379453>
     82 
     83 ; Hard-coded registers comes from the ABI.
     84 ; CHECK: wrapDistance:
     85 ; CHECK: cmp r1, #59
     86 ; CHECK-NEXT: itt le
     87 ; CHECK-NEXT: suble r0, r2, #1
     88 ; CHECK-NEXT: bxle lr
     89 ; CHECK-NEXT: subs [[REG:r[0-9]+]], #120
     90 ; CHECK-NEXT: cmp [[REG]], r1
     91 ; CHECK-NOT: it lt
     92 ; CHECK-NEXT: bge [[LABEL:.+]]
     93 ; Next BB
     94 ; CHECK-NOT: cmplt
     95 ; CHECK: cmp r0, #119
     96 ; CHECK-NEXT: itt le
     97 ; CHECK-NEXT: addle r0, r1, #1
     98 ; CHECK-NEXT: bxle lr
     99 ; Next BB
    100 ; CHECK: [[LABEL]]:
    101 ; CHECK-NEXT: subs r0, r1, r0
    102 ; CHECK-NEXT: bx lr
    103 define i32 @wrapDistance(i32 %tx, i32 %sx, i32 %w) {
    104 entry:
    105   %cmp = icmp slt i32 %sx, 60
    106   br i1 %cmp, label %if.then, label %if.else
    107 
    108 if.then:                                          ; preds = %entry
    109   %sub = add nsw i32 %w, -1
    110   br label %return
    111 
    112 if.else:                                          ; preds = %entry
    113   %sub1 = add nsw i32 %w, -120
    114   %cmp2 = icmp slt i32 %sub1, %sx
    115   %cmp3 = icmp slt i32 %tx, 120
    116   %or.cond = and i1 %cmp2, %cmp3
    117   br i1 %or.cond, label %if.then4, label %if.end5
    118 
    119 if.then4:                                         ; preds = %if.else
    120   %add = add nsw i32 %sx, 1
    121   br label %return
    122 
    123 if.end5:                                          ; preds = %if.else
    124   %sub6 = sub nsw i32 %sx, %tx
    125   br label %return
    126 
    127 return:                                           ; preds = %if.end5, %if.then4, %if.then
    128   %retval.0 = phi i32 [ %sub, %if.then ], [ %add, %if.then4 ], [ %sub6, %if.end5 ]
    129   ret i32 %retval.0
    130 }
    131