1; RUN: opt %loadPolly -polly-stmt-granularity=bb -polly-scops -analyze -polly-allow-modref-calls \ 2; RUN: -polly-invariant-load-hoisting=true \ 3; RUN: < %s | FileCheck %s 4; RUN: opt %loadPolly -polly-stmt-granularity=bb -polly-scops -polly-allow-nonaffine \ 5; RUN: -polly-invariant-load-hoisting=true \ 6; RUN: -polly-allow-modref-calls -analyze < %s | FileCheck %s --check-prefix=NONAFFINE 7 8; TODO: We should delinearize the accesses despite the use in a call to a 9; readonly function. For now we verify we do not delinearize them though. 10 11; CHECK: Function: ham 12; CHECK-NEXT: Region: %bb12---%bb28 13; CHECK-NEXT: Max Loop Depth: 1 14; CHECK-NEXT: Invariant Accesses: { 15; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0] 16; CHECK-NEXT: [tmp14, p_1] -> { Stmt_bb12[] -> MemRef_arg1[0] }; 17; CHECK-NEXT: Execution Context: [tmp14, p_1] -> { : } 18; CHECK-NEXT: } 19; CHECK-NEXT: Context: 20; CHECK-NEXT: [tmp14, p_1] -> { : -9223372036854775808 <= tmp14 <= 9223372036854775807 and -9223372036854775808 <= p_1 <= 9223372036854775807 } 21; CHECK-NEXT: Assumed Context: 22; CHECK-NEXT: [tmp14, p_1] -> { : } 23; CHECK-NEXT: Invalid Context: 24; CHECK-NEXT: [tmp14, p_1] -> { : tmp14 > 0 and (p_1 <= -1152921504606846977 or tmp14 >= 1152921504606846977 or p_1 >= 1152921504606846977 - tmp14) } 25; CHECK-NEXT: p0: %tmp14 26; CHECK-NEXT: p1: {0,+,(0 smax %tmp)}<%bb12> 27; CHECK-NEXT: Arrays { 28; CHECK-NEXT: i64 MemRef_arg1[*]; // Element size 8 29; CHECK-NEXT: i64 MemRef_tmp13; // Element size 8 30; CHECK-NEXT: [1000 x double]* MemRef_arg4[*]; // Element size 8 31; CHECK-NEXT: } 32; CHECK-NEXT: Arrays (Bounds as pw_affs) { 33; CHECK-NEXT: i64 MemRef_arg1[*]; // Element size 8 34; CHECK-NEXT: i64 MemRef_tmp13; // Element size 8 35; CHECK-NEXT: [1000 x double]* MemRef_arg4[*]; // Element size 8 36; CHECK-NEXT: } 37; CHECK-NEXT: Alias Groups (0): 38; CHECK-NEXT: n/a 39; CHECK-NEXT: Statements { 40; CHECK-NEXT: Stmt_bb12 41; CHECK-NEXT: Domain := 42; CHECK-NEXT: [tmp14, p_1] -> { Stmt_bb12[] }; 43; CHECK-NEXT: Schedule := 44; CHECK-NEXT: [tmp14, p_1] -> { Stmt_bb12[] -> [0, 0] }; 45; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1] 46; CHECK-NEXT: [tmp14, p_1] -> { Stmt_bb12[] -> MemRef_tmp13[] }; 47; CHECK-NEXT: Stmt_bb17 48; CHECK-NEXT: Domain := 49; CHECK-NEXT: [tmp14, p_1] -> { Stmt_bb17[i0] : 0 <= i0 < tmp14 }; 50; CHECK-NEXT: Schedule := 51; CHECK-NEXT: [tmp14, p_1] -> { Stmt_bb17[i0] -> [1, i0] }; 52; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0] 53; CHECK-NEXT: [tmp14, p_1] -> { Stmt_bb17[i0] -> MemRef_arg4[o0] }; 54; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0] 55; CHECK-NEXT: [tmp14, p_1] -> { Stmt_bb17[i0] -> MemRef_arg4[p_1 + i0] }; 56; CHECK-NEXT: } 57 58 59; NONAFFINE: Function: ham 60; NONAFFINE-NEXT: Region: %bb5---%bb32 61; NONAFFINE-NEXT: Max Loop Depth: 2 62; NONAFFINE-NEXT: Invariant Accesses: { 63; NONAFFINE-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0] 64; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb5[] -> MemRef_arg[0] }; 65; NONAFFINE-NEXT: Execution Context: [tmp9, tmp14] -> { : } 66; NONAFFINE-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0] 67; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb12[i0] -> MemRef_arg1[0] }; 68; NONAFFINE-NEXT: Execution Context: [tmp9, tmp14] -> { : } 69; NONAFFINE-NEXT: } 70; NONAFFINE-NEXT: Context: 71; NONAFFINE-NEXT: [tmp9, tmp14] -> { : -9223372036854775808 <= tmp9 <= 9223372036854775807 and -9223372036854775808 <= tmp14 <= 9223372036854775807 } 72; NONAFFINE-NEXT: Assumed Context: 73; NONAFFINE-NEXT: [tmp9, tmp14] -> { : } 74; NONAFFINE-NEXT: Invalid Context: 75; NONAFFINE-NEXT: [tmp9, tmp14] -> { : false } 76; NONAFFINE-NEXT: p0: %tmp9 77; NONAFFINE-NEXT: p1: %tmp14 78; NONAFFINE-NEXT: Arrays { 79; NONAFFINE-NEXT: i64 MemRef_arg[*]; // Element size 8 80; NONAFFINE-NEXT: i64 MemRef_arg1[*]; // Element size 8 81; NONAFFINE-NEXT: i64 MemRef_tmp7; // Element size 8 82; NONAFFINE-NEXT: i64 MemRef_tmp8; // Element size 8 83; NONAFFINE-NEXT: [1000 x double]* MemRef_arg4[*]; // Element size 8 84; NONAFFINE-NEXT: } 85; NONAFFINE-NEXT: Arrays (Bounds as pw_affs) { 86; NONAFFINE-NEXT: i64 MemRef_arg[*]; // Element size 8 87; NONAFFINE-NEXT: i64 MemRef_arg1[*]; // Element size 8 88; NONAFFINE-NEXT: i64 MemRef_tmp7; // Element size 8 89; NONAFFINE-NEXT: i64 MemRef_tmp8; // Element size 8 90; NONAFFINE-NEXT: [1000 x double]* MemRef_arg4[*]; // Element size 8 91; NONAFFINE-NEXT: } 92; NONAFFINE-NEXT: Alias Groups (0): 93; NONAFFINE-NEXT: n/a 94; NONAFFINE-NEXT: Statements { 95; NONAFFINE-NEXT: Stmt_bb5 96; NONAFFINE-NEXT: Domain := 97; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb5[] }; 98; NONAFFINE-NEXT: Schedule := 99; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb5[] -> [0, 0, 0] }; 100; NONAFFINE-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1] 101; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb5[] -> MemRef_tmp7[] }; 102; NONAFFINE-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1] 103; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb5[] -> MemRef_tmp8[] }; 104; NONAFFINE-NEXT: Stmt_bb17 105; NONAFFINE-NEXT: Domain := 106; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb17[i0, i1] : 0 <= i0 < tmp9 and 0 <= i1 < tmp14 }; 107; NONAFFINE-NEXT: Schedule := 108; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb17[i0, i1] -> [1, i0, i1] }; 109; NONAFFINE-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1] 110; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb17[i0, i1] -> MemRef_tmp7[] }; 111; NONAFFINE-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1] 112; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb17[i0, i1] -> MemRef_tmp8[] }; 113; NONAFFINE-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0] 114; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb17[i0, i1] -> MemRef_arg4[o0] }; 115; NONAFFINE-NEXT: MayWriteAccess := [Reduction Type: NONE] [Scalar: 0] 116; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb17[i0, i1] -> MemRef_arg4[o0] }; 117; NONAFFINE-NEXT: } 118 119target datalayout = "e-p:64:64:64-S128-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f16:16:16-f32:32:32-f64:64:64-f128:128:128-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" 120 121define void @ham(i64* noalias %arg, i64* noalias %arg1, i64* noalias %arg2, i64* noalias %arg3, [1000 x double]* noalias %arg4) gc "dummy" { 122bb: 123 br label %bb5 124 125bb5: ; preds = %bb 126 %tmp = load i64, i64* %arg1, align 8 127 %tmp6 = icmp slt i64 %tmp, 0 128 %tmp7 = select i1 %tmp6, i64 0, i64 %tmp 129 %tmp8 = xor i64 %tmp7, -1 130 %tmp9 = load i64, i64* %arg, align 8 131 %tmp10 = icmp sgt i64 %tmp9, 0 132 br i1 %tmp10, label %bb11, label %bb32 133 134bb11: ; preds = %bb5 135 br label %bb12 136 137bb12: ; preds = %bb28, %bb11 138 %tmp13 = phi i64 [ %tmp30, %bb28 ], [ 1, %bb11 ] 139 %tmp14 = load i64, i64* %arg1, align 8 140 %tmp15 = icmp sgt i64 %tmp14, 0 141 br i1 %tmp15, label %bb16, label %bb28 142 143bb16: ; preds = %bb12 144 br label %bb17 145 146bb17: ; preds = %bb17, %bb16 147 %tmp18 = phi i64 [ %tmp26, %bb17 ], [ 1, %bb16 ] 148 %tmp19 = mul i64 %tmp13, %tmp7 149 %tmp20 = add i64 %tmp19, %tmp8 150 %tmp21 = add i64 %tmp20, %tmp18 151 %tmp22 = add i64 %tmp18, %tmp13 152 %tmp23 = sitofp i64 %tmp22 to double 153 %tmp24 = getelementptr [1000 x double], [1000 x double]* %arg4, i64 0, i64 %tmp21 154 %bc = bitcast double* %tmp24 to i8* 155 %dummy = call i8* @llvm.gcread(i8* %bc, i8** null) 156 store double %tmp23, double* %tmp24, align 8 157 %tmp25 = icmp eq i64 %tmp18, %tmp14 158 %tmp26 = add i64 %tmp18, 1 159 br i1 %tmp25, label %bb27, label %bb17 160 161bb27: ; preds = %bb17 162 br label %bb28 163 164bb28: ; preds = %bb27, %bb12 165 %tmp29 = icmp eq i64 %tmp13, %tmp9 166 %tmp30 = add i64 %tmp13, 1 167 br i1 %tmp29, label %bb31, label %bb12 168 169bb31: ; preds = %bb28 170 br label %bb32 171 172bb32: ; preds = %bb31, %bb5 173 ret void 174} 175 176declare i8* @llvm.gcread(i8*, i8**) 177