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-ppcg -polly-process-unprofitable -polly-invariant-load-hoisting | FileCheck %s -check-prefix=CODEGEN 3 4; REQUIRES: pollyacc 5 6target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n8:16:32-S64" 7 8%S = type { i32, i32, [12 x %L] } 9%L = type { i32, i32, double, i32, i32, i32, i32, i32 } 10 11define void @test(%S* %cpi, i1 %b) { 12; SCOPS-LABEL: Region: %if.then14---%exit 13; SCOPS: Invariant Accesses: { 14; SCOPS-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0] 15; SCOPS-NEXT: [l2, l1] -> { Stmt_for_body_i[i0] -> MemRef_cpi[0, 0] }; 16; SCOPS-NEXT: Execution Context: [l2, l1] -> { : } 17; SCOPS-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0] 18; SCOPS-NEXT: [l2, l1] -> { Stmt_for_body_lr_ph_i[] -> MemRef_cpi[0, 1] }; 19; SCOPS-NEXT: Execution Context: [l2, l1] -> { : l2 > 0 } 20; SCOPS-NEXT: } 21; SCOPS: Arrays { 22; SCOPS-NEXT: i32 MemRef_cpi[*][(10 * %l1)]; // Element size 4 23; SCOPS-NEXT: } 24 25; Check that we gracefully handle failing invariant loads. 26; This test case is taken from: 27; test/Isl/CodeGen/invariant-load-dimension.ll 28 29; FIXME: Figure out how to actually generate code for this loop. 30; CODEGEN-NOT: LLVM ERROR: preloading invariant loads failed in function 31 32entry: 33 %nt = getelementptr inbounds %S, %S* %cpi, i32 0, i32 1 34 br i1 %b, label %if.then14, label %exit 35 36if.then14: 37 %ns = getelementptr inbounds %S, %S* %cpi, i32 0, i32 0 38 %l0 = load i32, i32* %ns, align 8 39 %cmp12.i = icmp sgt i32 %l0, 0 40 br i1 %cmp12.i, label %for.body.lr.ph.i, label %exit 41 42for.body.lr.ph.i: 43 %l1 = load i32, i32* %nt, align 4 44 br label %for.body.i 45 46for.body.i: 47 %phi = phi i32 [ 0, %for.body.lr.ph.i ], [ %inc, %for.body.i ] 48 %mul.i163 = mul nsw i32 %phi, %l1 49 %cv = getelementptr inbounds %S, %S* %cpi, i32 0, i32 2, i32 %mul.i163, i32 0 50 store i32 0, i32* %cv, align 8 51 %inc = add nuw nsw i32 %phi, 1 52 %l2 = load i32, i32* %ns, align 8 53 %cmp.i164 = icmp slt i32 %inc, %l2 54 br i1 %cmp.i164, label %for.body.i, label %exit 55 56exit: 57 ret void 58} 59