Home | History | Annotate | Download | only in AArch64
      1 ; RUN: llc -mtriple=aarch64-linux-gnu -verify-machineinstrs -o - %s | FileCheck %s
      2 ; LSR used to pick a sub-optimal solution due to the target responding
      3 ; conservatively to isLegalAddImmediate for negative values.
      4 
      5 declare void @foo(i32)
      6 
      7 define void @test(i32 %px) {
      8 ; CHECK_LABEL: test:
      9 ; CHECK_LABEL: %entry
     10 ; CHECK: subs
     11 ; CHECK-NEXT: csel
     12 entry:
     13   %sub = add nsw i32 %px, -1
     14   %cmp = icmp slt i32 %px, 1
     15   %.sub = select i1 %cmp, i32 0, i32 %sub
     16   br label %for.body
     17 
     18 for.body:
     19 ; CHECK_LABEL: %for.body
     20 ; CHECK:  cmp
     21 ; CHECK-NEXT:  b.eq
     22 ; CHECK-LABEL:  %if.then3
     23   %x.015 = phi i32 [ %inc, %for.inc ], [ %.sub, %entry ]
     24   %cmp2 = icmp eq i32 %x.015, %px
     25   br i1 %cmp2, label %for.inc, label %if.then3
     26 
     27 if.then3:
     28   tail call void @foo(i32 %x.015)
     29   br label %for.inc
     30 
     31 for.inc:
     32 ; CHECK_LABEL: %for.inc
     33 ; CHECK:  add
     34 ; CHECK-NEXT:  cmp
     35 ; CHECK:  b.le
     36 ; CHECK_LABEL: %for.cond.cleanup
     37   %inc = add nsw i32 %x.015, 1
     38   %cmp1 = icmp sgt i32 %x.015, %px
     39   br i1 %cmp1, label %for.cond.cleanup.loopexit, label %for.body
     40 
     41 for.cond.cleanup.loopexit:
     42   br label %for.cond.cleanup
     43 
     44 for.cond.cleanup:
     45   ret void
     46 }
     47