1; RUN: opt %loadNPMPolly -polly-process-unprofitable -polly-invariant-load-hoisting '-passes=print<polly-function-scops>' -disable-output < %s 2>&1 | FileCheck %s -check-prefix=SCOPS 2; RUN: opt %loadNPMPolly -S < %s -passes=polly-codegen -polly-process-unprofitable -polly-invariant-load-hoisting | FileCheck %s -check-prefix=CODEGEN 3 4target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n8:16:32-S64" 5 6%S = type { i32, i32, [12 x %L] } 7%L = type { i32, i32, double, i32, i32, i32, i32, i32 } 8 9define void @test(ptr %cpi, i1 %b) { 10; SCOPS-LABEL: Region: %if.then14---%exit 11; SCOPS: Invariant Accesses: { 12; SCOPS-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0] 13; SCOPS-NEXT: [l2, l1] -> { Stmt_for_body_i[i0] -> MemRef_cpi[0, 0] }; 14; SCOPS-NEXT: Execution Context: [l2, l1] -> { : } 15; SCOPS-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0] 16; SCOPS-NEXT: [l2, l1] -> { Stmt_for_body_lr_ph_i[] -> MemRef_cpi[0, 1] }; 17; SCOPS-NEXT: Execution Context: [l2, l1] -> { : l2 > 0 } 18; SCOPS-NEXT: } 19; SCOPS: Arrays { 20; SCOPS-NEXT: i32 MemRef_cpi[*][(10 * %l1)]; // Element size 4 21; SCOPS-NEXT: } 22 23; FIXME: Figure out how to actually generate code for this loop. 24; CODEGEN-LABEL: @test( 25; CODEGEN: polly.preload.begin: 26; CODEGEN-NEXT: br i1 false 27 28entry: 29 %nt = getelementptr inbounds %S, ptr %cpi, i32 0, i32 1 30 br i1 %b, label %if.then14, label %exit 31 32if.then14: 33 %l0 = load i32, ptr %cpi, align 8 34 %cmp12.i = icmp sgt i32 %l0, 0 35 br i1 %cmp12.i, label %for.body.lr.ph.i, label %exit 36 37for.body.lr.ph.i: 38 %l1 = load i32, ptr %nt, align 4 39 br label %for.body.i 40 41for.body.i: 42 %phi = phi i32 [ 0, %for.body.lr.ph.i ], [ %inc, %for.body.i ] 43 %mul.i163 = mul nsw i32 %phi, %l1 44 %cv = getelementptr inbounds %S, ptr %cpi, i32 0, i32 2, i32 %mul.i163, i32 0 45 store i32 0, ptr %cv, align 8 46 %inc = add nuw nsw i32 %phi, 1 47 %l2 = load i32, ptr %cpi, align 8 48 %cmp.i164 = icmp slt i32 %inc, %l2 49 br i1 %cmp.i164, label %for.body.i, label %exit 50 51exit: 52 ret void 53} 54