Home | History | Annotate | Download | only in LoopRotate
      1 ; RUN: opt -S -loop-rotate < %s | FileCheck %s
      2 
      3 @e = global i32 10
      4 
      5 declare void @f1(i32) convergent
      6 declare void @f2(i32)
      7 
      8 ; The call to f1 in the loop header shouldn't be duplicated (meaning, loop
      9 ; rotation shouldn't occur), because f1 is convergent.
     10 
     11 ; CHECK: call void @f1
     12 ; CHECK-NOT: call void @f1
     13 
     14 define void @test(i32 %x) {
     15 entry:
     16   br label %loop
     17 
     18 loop:
     19   %n.phi = phi i32 [ %n, %loop.fin ], [ 0, %entry ]
     20   call void @f1(i32 %n.phi)
     21   %cond = icmp eq i32 %n.phi, %x
     22   br i1 %cond, label %exit, label %loop.fin
     23 
     24 loop.fin:
     25   %n = add i32 %n.phi, 1
     26   call void @f2(i32 %n)
     27   br label %loop
     28 
     29 exit:
     30   ret void
     31 }
     32