1 2; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s 3; RUN: opt %loadPolly -polly-ast -analyze < %s | FileCheck %s --check-prefix=AST 4; 5; void f(int *A, int c, int N) { 6; switch (c) { 7; case -1: { 8; for (int j = N; j > 0; j--) 9; A[j] += A[j - 1]; 10; break; 11; } 12; case 1: { 13; for (int j = 1; j <= N; j++) 14; A[j] += A[j - 1]; 15; break; 16; } 17; } 18; } 19 20; CHECK: Statements { 21; CHECK-NEXT: Stmt_for_body 22; CHECK-NEXT: Domain := 23; CHECK-NEXT: [c, N] -> { Stmt_for_body[i0] : c = -1 and 0 <= i0 < N }; 24; CHECK-NEXT: Schedule := 25; CHECK-NEXT: [c, N] -> { Stmt_for_body[i0] -> [1, i0] }; 26; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0] 27; CHECK-NEXT: [c, N] -> { Stmt_for_body[i0] -> MemRef_A[-1 + N - i0] }; 28; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0] 29; CHECK-NEXT: [c, N] -> { Stmt_for_body[i0] -> MemRef_A[N - i0] }; 30; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0] 31; CHECK-NEXT: [c, N] -> { Stmt_for_body[i0] -> MemRef_A[N - i0] }; 32; CHECK-NEXT: Stmt_for_body_7 33; CHECK-NEXT: Domain := 34; CHECK-NEXT: [c, N] -> { Stmt_for_body_7[i0] : c = 1 and 0 <= i0 < N }; 35; CHECK-NEXT: Schedule := 36; CHECK-NEXT: [c, N] -> { Stmt_for_body_7[i0] -> [0, i0] }; 37; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0] 38; CHECK-NEXT: [c, N] -> { Stmt_for_body_7[i0] -> MemRef_A[i0] }; 39; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0] 40; CHECK-NEXT: [c, N] -> { Stmt_for_body_7[i0] -> MemRef_A[1 + i0] }; 41; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0] 42; CHECK-NEXT: [c, N] -> { Stmt_for_body_7[i0] -> MemRef_A[1 + i0] }; 43; CHECK-NEXT: } 44 45; AST: if (1) 46; 47; AST: if (c == 1) { 48; AST-NEXT: for (int c0 = 0; c0 < N; c0 += 1) 49; AST-NEXT: Stmt_for_body_7(c0); 50; AST-NEXT: } else if (c == -1) 51; AST-NEXT: for (int c0 = 0; c0 < N; c0 += 1) 52; AST-NEXT: Stmt_for_body(c0); 53; 54; AST: else 55; AST-NEXT: { /* original code */ } 56 57target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 58 59define void @f(i32* %A, i32 %c, i32 %N) { 60entry: 61 br label %entry.split 62 63entry.split: 64 switch i32 %c, label %sw.epilog [ 65 i32 -1, label %sw.bb 66 i32 1, label %sw.bb.3 67 ] 68 69sw.bb: ; preds = %entry 70 %tmp = sext i32 %N to i64 71 br label %for.cond 72 73for.cond: ; preds = %for.inc, %sw.bb 74 %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ %tmp, %sw.bb ] 75 %j.0 = phi i32 [ %N, %sw.bb ], [ %dec, %for.inc ] 76 %cmp = icmp sgt i64 %indvars.iv, 0 77 br i1 %cmp, label %for.body, label %for.end 78 79for.body: ; preds = %for.cond 80 %sub = add nsw i32 %j.0, -1 81 %idxprom = sext i32 %sub to i64 82 %arrayidx = getelementptr inbounds i32, i32* %A, i64 %idxprom 83 %tmp6 = load i32, i32* %arrayidx, align 4 84 %arrayidx2 = getelementptr inbounds i32, i32* %A, i64 %indvars.iv 85 %tmp7 = load i32, i32* %arrayidx2, align 4 86 %add = add nsw i32 %tmp7, %tmp6 87 store i32 %add, i32* %arrayidx2, align 4 88 br label %for.inc 89 90for.inc: ; preds = %for.body 91 %dec = add nsw i32 %j.0, -1 92 %indvars.iv.next = add nsw i64 %indvars.iv, -1 93 br label %for.cond 94 95for.end: ; preds = %for.cond 96 br label %sw.epilog 97 98sw.bb.3: ; preds = %entry 99 %tmp8 = sext i32 %N to i64 100 br label %for.cond.5 101 102for.cond.5: ; preds = %for.inc.14, %sw.bb.3 103 %indvars.iv3 = phi i64 [ %indvars.iv.next4, %for.inc.14 ], [ 1, %sw.bb.3 ] 104 %cmp6 = icmp sgt i64 %indvars.iv3, %tmp8 105 br i1 %cmp6, label %for.end.15, label %for.body.7 106 107for.body.7: ; preds = %for.cond.5 108 %tmp9 = add nsw i64 %indvars.iv3, -1 109 %arrayidx10 = getelementptr inbounds i32, i32* %A, i64 %tmp9 110 %tmp10 = load i32, i32* %arrayidx10, align 4 111 %arrayidx12 = getelementptr inbounds i32, i32* %A, i64 %indvars.iv3 112 %tmp11 = load i32, i32* %arrayidx12, align 4 113 %add13 = add nsw i32 %tmp11, %tmp10 114 store i32 %add13, i32* %arrayidx12, align 4 115 br label %for.inc.14 116 117for.inc.14: ; preds = %for.body.7 118 %indvars.iv.next4 = add nuw nsw i64 %indvars.iv3, 1 119 br label %for.cond.5 120 121for.end.15: ; preds = %for.cond.5 122 br label %sw.epilog 123 124sw.epilog: ; preds = %for.end.15, %for.end, %entry 125 ret void 126} 127