1 ; RUN: opt -passes=loop-load-elim -S < %s | FileCheck %s
3 ; Simple st->ld forwarding derived from a lexical forward dep, but
4 ; can't introduce runtime checks with a convergent call.
6 ; for (unsigned i = 0; i < 100; i++) {
7 ; A[i+1] = convergent(B[i]) + 2;
11 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
13 ; CHECK-LABEL: @f_convergent(
14 ; CHECK: call i32 @llvm.convergent(
15 ; CHECK-NOT: call i32 @llvm.convergent(
16 define void @f_convergent(ptr %A, ptr %B, ptr %C, i64 %N) #0 {
21 for.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
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
30 %b = load i32, ptr %Bidx, align 4
31 %convergent.b = call i32 @llvm.convergent(i32 %b)
33 %a_p1 = add i32 %convergent.b, 2
34 store i32 %a_p1, ptr %Aidx_next, align 4
36 %a = load i32, ptr %Aidx, align 1
38 store i32 %c, ptr %Cidx, align 4
40 %exitcond = icmp eq i64 %indvars.iv.next, %N
41 br i1 %exitcond, label %for.end, label %for.body
43 for.end: ; preds = %for.body
47 declare i32 @llvm.convergent(i32) #1
49 attributes #0 = { nounwind convergent }
50 attributes #1 = { nounwind readnone convergent }