1; RUN: opt -passes=loop-load-elim -S < %s | FileCheck %s 2 3; Simple st->ld forwarding derived from a lexical forward dep, but 4; can't introduce runtime checks with a convergent call. 5; 6; for (unsigned i = 0; i < 100; i++) { 7; A[i+1] = convergent(B[i]) + 2; 8; C[i] = A[i] * 2; 9; } 10 11target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 12 13; CHECK-LABEL: @f_convergent( 14; CHECK: call i32 @llvm.convergent( 15; CHECK-NOT: call i32 @llvm.convergent( 16define void @f_convergent(ptr %A, ptr %B, ptr %C, i64 %N) #0 { 17 18entry: 19 br label %for.body 20 21for.body: ; preds = %for.body, %entry 22 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ] 23 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 24 25 %Aidx_next = getelementptr inbounds i32, ptr %A, i64 %indvars.iv.next 26 %Bidx = getelementptr inbounds i32, ptr %B, i64 %indvars.iv 27 %Cidx = getelementptr inbounds i32, ptr %C, i64 %indvars.iv 28 %Aidx = getelementptr inbounds i32, ptr %A, i64 %indvars.iv 29 30 %b = load i32, ptr %Bidx, align 4 31 %convergent.b = call i32 @llvm.convergent(i32 %b) 32 33 %a_p1 = add i32 %convergent.b, 2 34 store i32 %a_p1, ptr %Aidx_next, align 4 35 36 %a = load i32, ptr %Aidx, align 1 37 %c = mul i32 %a, 2 38 store i32 %c, ptr %Cidx, align 4 39 40 %exitcond = icmp eq i64 %indvars.iv.next, %N 41 br i1 %exitcond, label %for.end, label %for.body 42 43for.end: ; preds = %for.body 44 ret void 45} 46 47declare i32 @llvm.convergent(i32) #1 48 49attributes #0 = { nounwind convergent } 50attributes #1 = { nounwind readnone convergent } 51