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