1; RUN: opt %loadPolly -polly-scops -polly-invariant-load-hoisting=true -analyze < %s | FileCheck %s 2; 3; Check that we do not consolidate the invariant loads to smp[order - 1] and 4; smp[order - 2] in the blocks %0 and %16. While they have the same pointer 5; operand (SCEV) they do not have the same access relation due to the 6; instantiation of "order" from their domain. 7; 8; CHECK: Invariant Accesses: { 9; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0] 10; CHECK-NEXT: [order, n] -> { Stmt_bb1[] -> MemRef_smp[1] }; 11; CHECK-NEXT: Execution Context: [order, n] -> { : order = 2 } 12; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0] 13; CHECK-NEXT: [order, n] -> { Stmt_bb1[] -> MemRef_smp[0] }; 14; CHECK-NEXT: Execution Context: [order, n] -> { : order = 2 } 15; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0] 16; CHECK-NEXT: [order, n] -> { Stmt_bb16[] -> MemRef_smp[2] }; 17; CHECK-NEXT: Execution Context: [order, n] -> { : order = 3 } 18; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0] 19; CHECK-NEXT: [order, n] -> { Stmt_bb16[] -> MemRef_smp[1] }; 20; CHECK-NEXT: Execution Context: [order, n] -> { : order = 3 } 21; CHECK-NEXT: } 22; 23; ModuleID = '/home/johannes/Downloads/test_case.ll' 24target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 25 26; Function Attrs: nounwind uwtable 27define void @encode_residual_fixed(i32* %res, i32* %smp, i32 %n, i32 %order) { 28bb: 29 br label %.split 30 31.split: ; preds = %bb 32 switch i32 %order, label %bb32 [ 33 i32 2, label %bb1 34 i32 3, label %bb16 35 ] 36 37bb1: ; preds = %.split 38 %tmp = add nsw i32 %order, -1 39 %tmp2 = sext i32 %tmp to i64 40 %tmp3 = getelementptr inbounds i32, i32* %smp, i64 %tmp2 41 %tmp4 = load i32, i32* %tmp3, align 4 42 %tmp5 = add nsw i32 %order, -2 43 %tmp6 = sext i32 %tmp5 to i64 44 %tmp7 = getelementptr inbounds i32, i32* %smp, i64 %tmp6 45 %tmp8 = load i32, i32* %tmp7, align 4 46 %tmp9 = sub nsw i32 %tmp4, %tmp8 47 %tmp10 = icmp slt i32 %order, %n 48 br i1 %tmp10, label %.lr.ph, label %.loopexit 49 50.lr.ph: ; preds = %bb1 51 %tmp11 = sext i32 %order to i64 52 br label %bb12 53 54bb12: ; preds = %bb12, %.lr.ph 55 %indvars.iv = phi i64 [ %tmp11, %.lr.ph ], [ %indvars.iv.next, %bb12 ] 56 %i.03 = phi i32 [ %order, %.lr.ph ], [ %tmp14, %bb12 ] 57 %tmp13 = getelementptr inbounds i32, i32* %res, i64 %indvars.iv 58 store i32 %tmp9, i32* %tmp13, align 4 59 %tmp14 = add nsw i32 %i.03, 2 60 %tmp15 = icmp slt i32 %tmp14, %n 61 %indvars.iv.next = add nsw i64 %indvars.iv, 2 62 br i1 %tmp15, label %bb12, label %..loopexit_crit_edge 63 64bb16: ; preds = %.split 65 %tmp17 = add nsw i32 %order, -1 66 %tmp18 = sext i32 %tmp17 to i64 67 %tmp19 = getelementptr inbounds i32, i32* %smp, i64 %tmp18 68 %tmp20 = load i32, i32* %tmp19, align 4 69 %tmp21 = add nsw i32 %order, -2 70 %tmp22 = sext i32 %tmp21 to i64 71 %tmp23 = getelementptr inbounds i32, i32* %smp, i64 %tmp22 72 %tmp24 = load i32, i32* %tmp23, align 4 73 %tmp25 = sub nsw i32 %tmp20, %tmp24 74 %tmp26 = icmp slt i32 %order, %n 75 br i1 %tmp26, label %.lr.ph5, label %.loopexit2 76 77.lr.ph5: ; preds = %bb16 78 %tmp27 = sext i32 %order to i64 79 br label %bb28 80 81bb28: ; preds = %bb28, %.lr.ph5 82 %indvars.iv6 = phi i64 [ %tmp27, %.lr.ph5 ], [ %indvars.iv.next7, %bb28 ] 83 %i.14 = phi i32 [ %order, %.lr.ph5 ], [ %tmp30, %bb28 ] 84 %tmp29 = getelementptr inbounds i32, i32* %res, i64 %indvars.iv6 85 store i32 %tmp25, i32* %tmp29, align 4 86 %tmp30 = add nsw i32 %i.14, 2 87 %tmp31 = icmp slt i32 %tmp30, %n 88 %indvars.iv.next7 = add nsw i64 %indvars.iv6, 2 89 br i1 %tmp31, label %bb28, label %..loopexit2_crit_edge 90 91..loopexit_crit_edge: ; preds = %bb12 92 br label %.loopexit 93 94.loopexit: ; preds = %..loopexit_crit_edge, %bb1 95 br label %bb32 96 97..loopexit2_crit_edge: ; preds = %bb28 98 br label %.loopexit2 99 100.loopexit2: ; preds = %..loopexit2_crit_edge, %bb16 101 br label %bb32 102 103bb32: ; preds = %.loopexit2, %.loopexit, %.split 104 %tmp33 = getelementptr inbounds i32, i32* %res, i64 2 105 %tmp34 = load i32, i32* %tmp33, align 4 106 %tmp35 = icmp eq i32 %tmp34, 5 107 br i1 %tmp35, label %bb37, label %bb36 108 109bb36: ; preds = %bb32 110 ret void 111 112bb37: ; preds = %bb32 113 ret void 114} 115