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