36 lines · plain
1; RUN: opt -passes=loop-load-elim -S < %s | FileCheck %s2 3; No loop-carried forwarding: The intervening store to A[i] kills the stored4; value from the previous iteration.5;6; for (unsigned i = 0; i < 100; i++) {7; A[i] = 1;8; A[i+1] = A[i] + B[i];9; }10 11target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"12 13define void @f(ptr noalias nocapture %A, ptr noalias nocapture readonly %B, i64 %N) {14entry:15 br label %for.body16 17for.body: ; preds = %for.body, %entry18; CHECK-NOT: %store_forwarded19 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]20 %arrayidx = getelementptr inbounds i32, ptr %A, i64 %indvars.iv21 store i32 1, ptr %arrayidx, align 422 %a = load i32, ptr %arrayidx, align 423 %arrayidxB = getelementptr inbounds i32, ptr %B, i64 %indvars.iv24 %b = load i32, ptr %arrayidxB, align 425; CHECK: %add = add i32 %b, %a26 %add = add i32 %b, %a27 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 128 %arrayidx_next = getelementptr inbounds i32, ptr %A, i64 %indvars.iv.next29 store i32 %add, ptr %arrayidx_next, align 430 %exitcond = icmp eq i64 %indvars.iv.next, %N31 br i1 %exitcond, label %for.end, label %for.body32 33for.end: ; preds = %for.body34 ret void35}36