1 ; RUN: opt %loadPolly -polly-process-unprofitable -polly-invariant-load-hoisting -polly-print-scops -disable-output < %s | 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
4 target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n8:16:32-S64"
6 %S = type { i32, i32, [12 x %L] }
7 %L = type { i32, i32, double, i32, i32, i32, i32, i32 }
9 define 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 }
20 ; SCOPS-NEXT: i32 MemRef_cpi[*][(10 * %l1)]; // Element size 4
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
29 %nt = getelementptr inbounds %S, ptr %cpi, i32 0, i32 1
30 br i1 %b, label %if.then14, label %exit
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
38 %l1 = load i32, ptr %nt, align 4
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