Home | History | Annotate | Download | only in ARM
      1 ; RUN: llc -mtriple=arm-eabi %s -o - | FileCheck %s
      2 
      3 ; This loop is rewritten with an indvar which counts down, which
      4 ; frees up a register from holding the trip count.
      5 
      6 define void @test(i32* %P, i32 %A, i32 %i) nounwind {
      7 entry:
      8 ; CHECK: str r1, [{{r.*}}, {{r.*}}, lsl #2]
      9         icmp eq i32 %i, 0               ; <i1>:0 [#uses=1]
     10         br i1 %0, label %return, label %bb
     11 
     12 bb:             ; preds = %bb, %entry
     13         %indvar = phi i32 [ 0, %entry ], [ %indvar.next, %bb ]          ; <i32> [#uses=2]
     14         %i_addr.09.0 = sub i32 %i, %indvar              ; <i32> [#uses=1]
     15         %tmp2 = getelementptr i32, i32* %P, i32 %i_addr.09.0         ; <i32*> [#uses=1]
     16         store i32 %A, i32* %tmp2
     17         %indvar.next = add i32 %indvar, 1               ; <i32> [#uses=2]
     18         icmp eq i32 %indvar.next, %i            ; <i1>:1 [#uses=1]
     19         br i1 %1, label %return, label %bb
     20 
     21 return:         ; preds = %bb, %entry
     22         ret void
     23 }
     24 
     25 ; This loop has a non-address use of the count-up indvar, so
     26 ; it'll remain. Now the original store uses a negative-stride address.
     27 
     28 define void @test_with_forced_iv(i32* %P, i32 %A, i32 %i) nounwind {
     29 entry:
     30 ; CHECK: str r1, [{{r.*}}, -{{r.*}}, lsl #2]
     31         icmp eq i32 %i, 0               ; <i1>:0 [#uses=1]
     32         br i1 %0, label %return, label %bb
     33 
     34 bb:             ; preds = %bb, %entry
     35         %indvar = phi i32 [ 0, %entry ], [ %indvar.next, %bb ]          ; <i32> [#uses=2]
     36         %i_addr.09.0 = sub i32 %i, %indvar              ; <i32> [#uses=1]
     37         %tmp2 = getelementptr i32, i32* %P, i32 %i_addr.09.0         ; <i32*> [#uses=1]
     38         store i32 %A, i32* %tmp2
     39         store i32 %indvar, i32* null
     40         %indvar.next = add i32 %indvar, 1               ; <i32> [#uses=2]
     41         icmp eq i32 %indvar.next, %i            ; <i1>:1 [#uses=1]
     42         br i1 %1, label %return, label %bb
     43 
     44 return:         ; preds = %bb, %entry
     45         ret void
     46 }
     47 
     48