Home | History | Annotate | Download | only in Hexagon
      1 ; RUN: llc -march=hexagon -mcpu=hexagonv5 -enable-pipeliner -verify-machineinstrs < %s | FileCheck %s
      2 
      3 ; If the trip count is a compile-time constant, then decrement it instead
      4 ; of computing a new LC0 value.
      5 
      6 ; CHECK-LABEL: @test
      7 ; CHECK: loop0(.LBB0_1,#999)
      8 
      9 define i32 @test(i32* %A, i32* %B, i32 %count) {
     10 entry:
     11   br label %for.body
     12 
     13 for.body:
     14   %sum.02 = phi i32 [ 0, %entry ], [ %add, %for.body ]
     15   %arrayidx.phi = phi i32* [ %A, %entry ], [ %arrayidx.inc, %for.body ]
     16   %i.01 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
     17   %0 = load i32, i32* %arrayidx.phi, align 4
     18   %add = add nsw i32 %0, %sum.02
     19   %inc = add nsw i32 %i.01, 1
     20   %exitcond = icmp eq i32 %inc, 1000
     21   %arrayidx.inc = getelementptr i32, i32* %arrayidx.phi, i32 1
     22   br i1 %exitcond, label %for.end, label %for.body
     23 
     24 for.end:
     25   ret i32 %add
     26 }
     27 
     28 ; The constant trip count is small enough that the kernel is not executed.
     29 
     30 ; CHECK-LABEL: @test1
     31 ; CHECK-NOT: loop0(
     32 
     33 define i32 @test1(i32* %A, i32* %B, i32 %count) {
     34 entry:
     35   br label %for.body
     36 
     37 for.body:
     38   %sum.02 = phi i32 [ 0, %entry ], [ %add, %for.body ]
     39   %arrayidx.phi = phi i32* [ %A, %entry ], [ %arrayidx.inc, %for.body ]
     40   %i.01 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
     41   %0 = load i32, i32* %arrayidx.phi, align 4
     42   %add = add nsw i32 %0, %sum.02
     43   %inc = add nsw i32 %i.01, 1
     44   %exitcond = icmp eq i32 %inc, 1
     45   %arrayidx.inc = getelementptr i32, i32* %arrayidx.phi, i32 1
     46   br i1 %exitcond, label %for.end, label %for.body
     47 
     48 for.end:
     49   ret i32 %add
     50 }
     51 
     52