1; RUN: opt %loadPolly < %s -analyze -polly-scops -polly-process-unprofitable -polly-invariant-load-hoisting | FileCheck %s -check-prefix=SCOPS 2; RUN: opt %loadPolly -S < %s -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(%S* %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, %S* %cpi, i32 0, i32 1 30 br i1 %b, label %if.then14, label %exit 31 32if.then14: 33 %ns = getelementptr inbounds %S, %S* %cpi, i32 0, i32 0 34 %l0 = load i32, i32* %ns, align 8 35 %cmp12.i = icmp sgt i32 %l0, 0 36 br i1 %cmp12.i, label %for.body.lr.ph.i, label %exit 37 38for.body.lr.ph.i: 39 %l1 = load i32, i32* %nt, align 4 40 br label %for.body.i 41 42for.body.i: 43 %phi = phi i32 [ 0, %for.body.lr.ph.i ], [ %inc, %for.body.i ] 44 %mul.i163 = mul nsw i32 %phi, %l1 45 %cv = getelementptr inbounds %S, %S* %cpi, i32 0, i32 2, i32 %mul.i163, i32 0 46 store i32 0, i32* %cv, align 8 47 %inc = add nuw nsw i32 %phi, 1 48 %l2 = load i32, i32* %ns, align 8 49 %cmp.i164 = icmp slt i32 %inc, %l2 50 br i1 %cmp.i164, label %for.body.i, label %exit 51 52exit: 53 ret void 54} 55