Home | History | Annotate | Download | only in ARM
      1 ; RUN: llc -mtriple=thumbv7-apple-ios -disable-block-placement < %s | FileCheck %s
      2 ; RUN: llc -mtriple=armv7-apple-ios   -disable-block-placement < %s | FileCheck %s
      3 
      4 ; LLVM IR optimizers canonicalize icmp+select this way.
      5 ; Make sure that TwoAddressInstructionPass can commute the corresponding
      6 ; MOVCC instructions to avoid excessive copies in one of the if blocks.
      7 ;
      8 ; CHECK: %if.then
      9 ; CHECK-NOT: mov
     10 ; CHECK: movlo
     11 ; CHECK: movlo
     12 ; CHECK-NOT: mov
     13 
     14 ; CHECK: %if.else
     15 ; CHECK-NOT: mov
     16 ; CHECK: movls
     17 ; CHECK: movls
     18 ; CHECK-NOT: mov
     19 
     20 ; This is really an LSR test: Make sure that cmp is using the incremented
     21 ; induction variable.
     22 ; CHECK: %if.end8
     23 ; CHECK: add{{(s|\.w)?}} [[IV:r[0-9]+]], {{.*}}#1
     24 ; CHECK: cmp [[IV]], #
     25 
     26 define i32 @f(i32* nocapture %a, i32 %Pref) nounwind ssp {
     27 entry:
     28   br label %for.body
     29 
     30 for.body:                                         ; preds = %entry, %if.end8
     31   %i.012 = phi i32 [ 0, %entry ], [ %inc, %if.end8 ]
     32   %BestCost.011 = phi i32 [ -1, %entry ], [ %BestCost.1, %if.end8 ]
     33   %BestIdx.010 = phi i32 [ 0, %entry ], [ %BestIdx.1, %if.end8 ]
     34   %arrayidx = getelementptr inbounds i32* %a, i32 %i.012
     35   %0 = load i32* %arrayidx, align 4
     36   %mul = mul i32 %0, %0
     37   %sub = add nsw i32 %i.012, -5
     38   %cmp2 = icmp eq i32 %sub, %Pref
     39   br i1 %cmp2, label %if.else, label %if.then
     40 
     41 if.then:                                          ; preds = %for.body
     42   %cmp3 = icmp ult i32 %mul, %BestCost.011
     43   %i.0.BestIdx.0 = select i1 %cmp3, i32 %i.012, i32 %BestIdx.010
     44   %mul.BestCost.0 = select i1 %cmp3, i32 %mul, i32 %BestCost.011
     45   br label %if.end8
     46 
     47 if.else:                                          ; preds = %for.body
     48   %cmp5 = icmp ugt i32 %mul, %BestCost.011
     49   %BestIdx.0.i.0 = select i1 %cmp5, i32 %BestIdx.010, i32 %i.012
     50   %BestCost.0.mul = select i1 %cmp5, i32 %BestCost.011, i32 %mul
     51   br label %if.end8
     52 
     53 if.end8:                                          ; preds = %if.else, %if.then
     54   %BestIdx.1 = phi i32 [ %i.0.BestIdx.0, %if.then ], [ %BestIdx.0.i.0, %if.else ]
     55   %BestCost.1 = phi i32 [ %mul.BestCost.0, %if.then ], [ %BestCost.0.mul, %if.else ]
     56   store i32 %mul, i32* %arrayidx, align 4
     57   %inc = add i32 %i.012, 1
     58   %cmp = icmp eq i32 %inc, 11
     59   br i1 %cmp, label %for.end, label %for.body
     60 
     61 for.end:                                          ; preds = %if.end8
     62   ret i32 %BestIdx.1
     63 }
     64