1; RUN: opt %loadPolly -basic-aa -sroa -instcombine -simplifycfg -tailcallopt \ 2; RUN: -simplifycfg -reassociate -loop-rotate -instcombine -indvars \ 3; RUN: -polly-prepare -polly-scops -analyze < %s \ 4; RUN: \ 5; RUN: | FileCheck %s --check-prefix=NOLICM 6 7; RUN: opt %loadPolly -basic-aa -sroa -instcombine -simplifycfg -tailcallopt \ 8; RUN: -simplifycfg -reassociate -loop-rotate -instcombine -indvars -licm \ 9; RUN: -polly-prepare -polly-scops -analyze < %s \ 10; RUN: \ 11; RUN: | FileCheck %s --check-prefix=LICM 12 13; void foo(int n, float A[static const restrict n], float x) { 14; // (0) 15; for (int i = 0; i < 5; i += 1) { 16; for (int j = 0; j < n; j += 1) { 17; x = 7; // (1) 18; } 19; A[0] = x; // (3) 20; } 21; // (4) 22; } 23 24; LICM: Statements 25; NOLICM: Statements 26 27target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 28 29define void @foo(i32 %n, float* noalias nonnull %A, float %x) { 30entry: 31 %n.addr = alloca i32, align 4 32 %A.addr = alloca float*, align 8 33 %x.addr = alloca float, align 4 34 %i = alloca i32, align 4 35 %j = alloca i32, align 4 36 store i32 %n, i32* %n.addr, align 4 37 store float* %A, float** %A.addr, align 8 38 store float %x, float* %x.addr, align 4 39 %tmp = load i32, i32* %n.addr, align 4 40 %tmp1 = zext i32 %tmp to i64 41 store i32 0, i32* %i, align 4 42 br label %for.cond 43 44for.cond: ; preds = %for.inc.4, %entry 45 %tmp2 = load i32, i32* %i, align 4 46 %cmp = icmp slt i32 %tmp2, 5 47 br i1 %cmp, label %for.body, label %for.end.6 48 49for.body: ; preds = %for.cond 50 store i32 0, i32* %j, align 4 51 br label %for.cond.1 52 53for.cond.1: ; preds = %for.inc, %for.body 54 %tmp3 = load i32, i32* %j, align 4 55 %tmp4 = load i32, i32* %n.addr, align 4 56 %cmp2 = icmp slt i32 %tmp3, %tmp4 57 br i1 %cmp2, label %for.body.3, label %for.end 58 59for.body.3: ; preds = %for.cond.1 60 store float 7.000000e+00, float* %x.addr, align 4 61 br label %for.inc 62 63for.inc: ; preds = %for.body.3 64 %tmp5 = load i32, i32* %j, align 4 65 %add = add nsw i32 %tmp5, 1 66 store i32 %add, i32* %j, align 4 67 br label %for.cond.1 68 69for.end: ; preds = %for.cond.1 70 %tmp6 = load float, float* %x.addr, align 4 71 %tmp7 = load float*, float** %A.addr, align 8 72 %arrayidx = getelementptr inbounds float, float* %tmp7, i64 0 73 store float %tmp6, float* %arrayidx, align 4 74 br label %for.inc.4 75 76for.inc.4: ; preds = %for.end 77 %tmp8 = load i32, i32* %i, align 4 78 %add5 = add nsw i32 %tmp8, 1 79 store i32 %add5, i32* %i, align 4 80 br label %for.cond 81 82for.end.6: ; preds = %for.cond 83 ret void 84} 85 86; CHECK: Statements { 87; CHECK: Stmt_for_end 88; CHECK: } 89