[ZoneAlgo] Fix PHI inconsistency in invalid contexts.
[polly-mirror.git] / test / ScopInfo / stmt_with_read_but_without_sideffect.ll
blob9d72bf08765214cdb8888e9374606404588bf36c
1 ; RUN: opt %loadPolly -polly-delicm -analyze < %s | FileCheck %s
3 ; The statement Stmt_for_if_else_1 should be removed because it has no
4 ; sideeffects.  But it has a use of MemRef_tmp21 that must also be
5 ; removed from every list containing it.
6 ; This is a test-case meant for ScopInfo, but only later pass iterate
7 ; over the uses of MemRef_tmp21 of which the use by Stmt_for_if_else_1
8 ; should have been removed. We use -polly-delicm to trigger such an
9 ; iteration of an already deleted MemoryAccess.
11 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
13 @ATH = external dso_local unnamed_addr constant [88 x float], align 16
15 define void @setup_tone_curves() {
16 entry:
17   %ath = alloca [56 x float], align 16
18   br label %for.body
20 for.cond176.preheader:                            ; preds = %for.cond107.preheader
21   unreachable
23 for.body:                                         ; preds = %for.cond107.preheader, %entry
24   %indvars.iv999 = phi i64 [ 0, %entry ], [ %indvars.iv.next1000, %for.cond107.preheader ]
25   %tmp5 = shl nsw i64 %indvars.iv999, 2
26   br label %for.cond7.preheader
28 for.cond33.preheader:                             ; preds = %for.inc.1
29   br label %for.cond107.preheader
31 for.cond7.preheader:                              ; preds = %for.inc.1, %for.body
32   %indvars.iv958 = phi i64 [ 0, %for.body ], [ %indvars.iv.next959, %for.inc.1 ]
33   %tmp20 = add nuw nsw i64 %indvars.iv958, %tmp5
34   %arrayidx = getelementptr inbounds [88 x float], [88 x float]* @ATH, i64 0, i64 %tmp20
35   %tmp21 = load float, float* %arrayidx, align 4
36   %tmp22 = add nuw nsw i64 %tmp20, 1
37   %cmp12.1 = icmp ult i64 %tmp22, 88
38   br i1 %cmp12.1, label %if.then.1, label %if.else.1
40 for.cond107.preheader:                            ; preds = %for.cond33.preheader
41   %indvars.iv.next1000 = add nuw nsw i64 %indvars.iv999, 1
42   br i1 undef, label %for.cond176.preheader, label %for.body
44 if.else.1:                                        ; preds = %for.cond7.preheader
45   %cmp23.1 = fcmp ogt float %tmp21, -3.000000e+01
46   br label %for.inc.1
48 if.then.1:                                        ; preds = %for.cond7.preheader
49   %arrayidx.1 = getelementptr inbounds [88 x float], [88 x float]* @ATH, i64 0, i64 %tmp22
50   %tmp155 = load float, float* %arrayidx.1, align 4
51   %cmp16.1 = fcmp ogt float %tmp21, %tmp155
52   br label %for.inc.1
54 for.inc.1:                                        ; preds = %if.then.1, %if.else.1
55   %min.1.1 = phi float [ %tmp155, %if.then.1 ], [ -3.000000e+01, %if.else.1 ]
56   %arrayidx.2 = getelementptr inbounds [88 x float], [88 x float]* @ATH, i64 0, i64 0
57   %tmp157 = load float, float* %arrayidx.2, align 4
58   %cmp16.2 = fcmp ogt float %min.1.1, %tmp157
59   %arrayidx.3 = getelementptr inbounds [88 x float], [88 x float]* @ATH, i64 0, i64 0
60   %tmp159 = load float, float* %arrayidx.3, align 4
61   %cmp16.3 = fcmp ogt float %tmp157, %tmp159
62   %arrayidx29 = getelementptr inbounds [56 x float], [56 x float]* %ath, i64 0, i64 %indvars.iv958
63   store float %tmp159, float* %arrayidx29, align 4
64   %indvars.iv.next959 = add nuw nsw i64 %indvars.iv958, 1
65   %exitcond961 = icmp eq i64 %indvars.iv.next959, 56
66   br i1 %exitcond961, label %for.cond33.preheader, label %for.cond7.preheader
70 ; CHECK:      After accesses {
71 ; CHECK-NEXT:     Stmt_for_cond7_preheader
72 ; CHECK-NEXT:             ReadAccess :=       [Reduction Type: NONE] [Scalar: 0]
73 ; CHECK-NEXT:                 [p_0] -> { Stmt_for_cond7_preheader[i0] -> MemRef_ATH[4p_0 + i0] };
74 ; CHECK-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 1]
75 ; CHECK-NEXT:                 [p_0] -> { Stmt_for_cond7_preheader[i0] -> MemRef_tmp21[] };
76 ; CHECK-NEXT:            new: [p_0] -> { Stmt_for_cond7_preheader[i0] -> MemRef_ath[i0] };
77 ; CHECK-NEXT:     Stmt_if_then_1
78 ; CHECK-NEXT:             ReadAccess :=       [Reduction Type: NONE] [Scalar: 0]
79 ; CHECK-NEXT:                 [p_0] -> { Stmt_if_then_1[i0] -> MemRef_ATH[1 + 4p_0 + i0] };
80 ; CHECK-NEXT:             ReadAccess :=       [Reduction Type: NONE] [Scalar: 1]
81 ; CHECK-NEXT:                 [p_0] -> { Stmt_if_then_1[i0] -> MemRef_tmp21[] };
82 ; CHECK-NEXT:            new: [p_0] -> { Stmt_if_then_1[i0] -> MemRef_ath[i0] };
83 ; CHECK-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 1]
84 ; CHECK-NEXT:                 [p_0] -> { Stmt_if_then_1[i0] -> MemRef_min_1_1__phi[] };
85 ; CHECK-NEXT:            new: [p_0] -> { Stmt_if_then_1[i0] -> MemRef_ath[i0] };
86 ; CHECK-NEXT:     Stmt_if_else_1_last
87 ; CHECK-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 1]
88 ; CHECK-NEXT:                 [p_0] -> { Stmt_if_else_1_last[i0] -> MemRef_min_1_1__phi[] };
89 ; CHECK-NEXT:            new: [p_0] -> { Stmt_if_else_1_last[i0] -> MemRef_ath[i0] : p_0 <= 576460752303423487 };
90 ; CHECK-NEXT:     Stmt_for_inc_1
91 ; CHECK-NEXT:             ReadAccess :=       [Reduction Type: NONE] [Scalar: 1]
92 ; CHECK-NEXT:                 [p_0] -> { Stmt_for_inc_1[i0] -> MemRef_min_1_1__phi[] };
93 ; CHECK-NEXT:            new: [p_0] -> { Stmt_for_inc_1[i0] -> MemRef_ath[i0] };
94 ; CHECK-NEXT:             ReadAccess :=       [Reduction Type: NONE] [Scalar: 0]
95 ; CHECK-NEXT:                 [p_0] -> { Stmt_for_inc_1[i0] -> MemRef_ATH[0] };
96 ; CHECK-NEXT:             ReadAccess :=       [Reduction Type: NONE] [Scalar: 0]
97 ; CHECK-NEXT:                 [p_0] -> { Stmt_for_inc_1[i0] -> MemRef_ATH[0] };
98 ; CHECK-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 0]
99 ; CHECK-NEXT:                 [p_0] -> { Stmt_for_inc_1[i0] -> MemRef_ath[i0] };
100 ; CHECK-NEXT: }