53 lines · plain
1; RUN: opt -passes=loop-load-elim -S < %s | FileCheck %s2; RUN: opt -passes=loop-load-elim -S -runtime-check-per-loop-load-elim=2 < %s | FileCheck %s --check-prefix=AGGRESSIVE3 4; This needs two pairs of memchecks (A * { C, D }) for a single load5; elimination which is considered to expansive by default.6;7; for (unsigned i = 0; i < 100; i++) {8; A[i+1] = B[i] + 2;9; C[i] = A[i] * 2;10; D[i] = 2;11; }12 13target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"14 15define void @f(ptr %A, ptr %B, ptr %C, i64 %N, ptr %D) {16entry:17 br label %for.body18 19; AGGRESSIVE: for.body.lver.check:20; AGGRESSIVE: %found.conflict{{.*}} =21; AGGRESSIVE: %found.conflict{{.*}} =22; AGGRESSIVE-NOT: %found.conflict{{.*}} =23 24for.body: ; preds = %for.body, %entry25; CHECK-NOT: %store_forwarded =26; AGGRESSIVE: %store_forwarded =27 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]28 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 129 30 %Aidx_next = getelementptr inbounds i32, ptr %A, i64 %indvars.iv.next31 %Bidx = getelementptr inbounds i32, ptr %B, i64 %indvars.iv32 %Cidx = getelementptr inbounds i32, ptr %C, i64 %indvars.iv33 %Aidx = getelementptr inbounds i32, ptr %A, i64 %indvars.iv34 %Didx = getelementptr inbounds i32, ptr %D, i64 %indvars.iv35 36 %b = load i32, ptr %Bidx, align 437 %a_p1 = add i32 %b, 238 store i32 %a_p1, ptr %Aidx_next, align 439 40 %a = load i32, ptr %Aidx, align 441; CHECK: %c = mul i32 %a, 242; AGGRESSIVE: %c = mul i32 %store_forwarded, 243 %c = mul i32 %a, 244 store i32 %c, ptr %Cidx, align 445 store i32 2, ptr %Didx, align 446 47 %exitcond = icmp eq i64 %indvars.iv.next, %N48 br i1 %exitcond, label %for.end, label %for.body49 50for.end: ; preds = %for.body51 ret void52}53