86 lines · plain
1; RUN: opt %loadNPMPolly '-passes=polly-custom<scops>' -polly-print-scops -polly-invariant-load-hoisting=true -disable-output < %s 2>&1 | FileCheck %s2;3; CHECK: Invariant Accesses: {4; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]5; CHECK-NEXT: [LB, UB] -> { Stmt_for_body[i0] -> MemRef_LBptr[0] };6; CHECK-NEXT: Execution Context: [LB, UB] -> { : }7; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]8; CHECK-NEXT: [LB, UB] -> { Stmt_do_cond[i0, i1] -> MemRef_UBptr[0] };9; CHECK-NEXT: Execution Context: [LB, UB] -> { : }10; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]11; CHECK-NEXT: [LB, UB] -> { Stmt_if_then[i0, i1] -> MemRef_V[0] };12; CHECK-NEXT: Execution Context: [LB, UB] -> { : LB >= 6 or (UB > LB and UB >= 6) }13; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]14; CHECK-NEXT: [LB, UB] -> { Stmt_if_else[i0, i1] -> MemRef_U[0] };15; CHECK-NEXT: Execution Context: [LB, UB] -> { : LB <= 5 }16; CHECK-NEXT: }17;18; void f(int *restrict A, int *restrict V, int *restrict U, int *restrict UB,19; int *restrict LB) {20; for (int i = 0; i < 100; i++) {21; int j = /* invariant load */ *LB;22; do {23; if (j > 5)24; A[i] += /* invariant load */ *V;25; else26; A[i] += /* invariant load */ *U;27; } while (j++ < /* invariant load */ *UB);28; }29; }30;31target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"32 33define void @f(ptr noalias %A, ptr noalias %V, ptr noalias %U, ptr noalias %UBptr, ptr noalias %LBptr) {34entry:35 br label %for.cond36 37for.cond: ; preds = %for.inc, %entry38 %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %entry ]39 %exitcond = icmp ne i64 %indvars.iv, 10040 br i1 %exitcond, label %for.body, label %for.end41 42for.body: ; preds = %for.cond43 %LB = load i32, ptr %LBptr, align 444 br label %do.body45 46do.body: ; preds = %do.cond, %for.body47 %j.0 = phi i32 [ %LB, %for.body ], [ %inc, %do.cond ]48 %cmp1 = icmp sgt i32 %j.0, 549 br i1 %cmp1, label %if.then, label %if.else50 51if.then: ; preds = %do.body52 %tmp1 = load i32, ptr %V, align 453 %arrayidx = getelementptr inbounds i32, ptr %A, i64 %indvars.iv54 %tmp2 = load i32, ptr %arrayidx, align 455 %add = add nsw i32 %tmp2, %tmp156 store i32 %add, ptr %arrayidx, align 457 br label %if.end58 59if.else: ; preds = %do.body60 %tmp3 = load i32, ptr %U, align 461 %arrayidx3 = getelementptr inbounds i32, ptr %A, i64 %indvars.iv62 %tmp4 = load i32, ptr %arrayidx3, align 463 %add4 = add nsw i32 %tmp4, %tmp364 store i32 %add4, ptr %arrayidx3, align 465 br label %if.end66 67if.end: ; preds = %if.else, %if.then68 br label %do.cond69 70do.cond: ; preds = %if.end71 %inc = add nsw i32 %j.0, 172 %UB = load i32, ptr %UBptr, align 473 %cmp5 = icmp slt i32 %j.0, %UB74 br i1 %cmp5, label %do.body, label %do.end75 76do.end: ; preds = %do.cond77 br label %for.inc78 79for.inc: ; preds = %do.end80 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 181 br label %for.cond82 83for.end: ; preds = %for.cond84 ret void85}86