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