[ZoneAlgo] Fix PHI inconsistency in invalid contexts.
[polly-mirror.git] / test / DeLICM / pr41656.ll
blob4af478e99bfe44c87aa0a4e69dec4972054feadc
1 ; RUN: opt %loadPolly -polly-delicm -analyze < %s | FileCheck %s
3 ; llvm.org/PR41656
4
5 ; This test case has an InvalidContext such that part of the predecessors
6 ; of for.body.us.i lie within the invalid context. This causes a
7 ; consistency check withing the invalid context of PR41656 to fail.
9 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
11 define dso_local void @main() local_unnamed_addr #0 {
12 entry:
13   %call24 = tail call i32 @av_get_channel_layout_nb_channels() #2
14   br label %if.end30
16 if.end30:                                         ; preds = %entry
17   br i1 undef, label %if.then40, label %do.body.preheader
19 do.body.preheader:                                ; preds = %if.end30
20   %idx.ext.i = sext i32 %call24 to i64
21   %wide.trip.count.i = zext i32 %call24 to i64
22   %0 = load double*, double** undef, align 8, !tbaa !1
23   br label %for.body.us.preheader.i
25 if.then40:                                        ; preds = %if.end30
26   unreachable
28 for.body.us.preheader.i:                          ; preds = %do.body.preheader
29   br i1 false, label %for.body.us.i.us, label %for.body.us.i
31 for.body.us.i.us:                                 ; preds = %for.body.us.preheader.i
32   br label %fill_samples.exit
34 for.body.us.i:                                    ; preds = %for.cond2.for.end_crit_edge.us.i, %for.body.us.preheader.i
35   %t.1 = phi double [ undef, %for.cond2.for.end_crit_edge.us.i ], [ 0.000000e+00, %for.body.us.preheader.i ]
36   %i.05.us.i = phi i32 [ %inc8.us.i, %for.cond2.for.end_crit_edge.us.i ], [ 0, %for.body.us.preheader.i ]
37   %dstp.03.us.i = phi double* [ %add.ptr.us.i, %for.cond2.for.end_crit_edge.us.i ], [ %0, %for.body.us.preheader.i ]
38   %mul.us.i = fmul nsz double %t.1, 0x40A59933FC6A96C1
39   %1 = call nsz double @llvm.sin.f64(double %mul.us.i) #2
40   store double %1, double* %dstp.03.us.i, align 8, !tbaa !5
41   %2 = bitcast double* %dstp.03.us.i to i64*
42   br label %for.body5.us.for.body5.us_crit_edge.i
44 for.body5.us.for.body5.us_crit_edge.i:            ; preds = %for.body5.us.for.body5.us_crit_edge.i.for.body5.us.for.body5.us_crit_edge.i_crit_edge, %for.body.us.i
45   %indvars.iv.next.i66 = phi i64 [ 2, %for.body.us.i ], [ %indvars.iv.next.i, %for.body5.us.for.body5.us_crit_edge.i.for.body5.us.for.body5.us_crit_edge.i_crit_edge ]
46   %indvars.iv.next.i = add nuw nsw i64 %indvars.iv.next.i66, 1
47   %exitcond.i = icmp eq i64 %indvars.iv.next.i, %wide.trip.count.i
48   br i1 %exitcond.i, label %for.cond2.for.end_crit_edge.us.i, label %for.body5.us.for.body5.us_crit_edge.i.for.body5.us.for.body5.us_crit_edge.i_crit_edge
50 for.body5.us.for.body5.us_crit_edge.i.for.body5.us.for.body5.us_crit_edge.i_crit_edge: ; preds = %for.body5.us.for.body5.us_crit_edge.i
51   %.pre10.i.pre = load i64, i64* %2, align 8, !tbaa !5
52   br label %for.body5.us.for.body5.us_crit_edge.i
54 for.cond2.for.end_crit_edge.us.i:                 ; preds = %for.body5.us.for.body5.us_crit_edge.i
55   %add.ptr.us.i = getelementptr inbounds double, double* %dstp.03.us.i, i64 %idx.ext.i
56   %inc8.us.i = add nuw nsw i32 %i.05.us.i, 1
57   %exitcond7.i = icmp eq i32 %inc8.us.i, 1024
58   br i1 %exitcond7.i, label %fill_samples.exit, label %for.body.us.i
60 fill_samples.exit:                                ; preds = %for.cond2.for.end_crit_edge.us.i, %for.body.us.i.us
61   ret void
64 declare dso_local i32 @av_get_channel_layout_nb_channels() local_unnamed_addr #0
66 ; Function Attrs: nounwind readnone speculatable
67 declare double @llvm.sin.f64(double) #1
69 attributes #0 = { "use-soft-float"="false" }
70 attributes #1 = { nounwind readnone speculatable }
71 attributes #2 = { nounwind }
73 !llvm.ident = !{!0}
75 !0 = !{!"clang version 9.0.0 (https://github.com/llvm/llvm-project.git 2436237895b70ed44cf256f67eb2f74e147eb559)"}
76 !1 = !{!2, !2, i64 0}
77 !2 = !{!"any pointer", !3, i64 0}
78 !3 = !{!"omnipotent char", !4, i64 0}
79 !4 = !{!"Simple C/C++ TBAA"}
80 !5 = !{!6, !6, i64 0}
81 !6 = !{!"double", !3, i64 0}
84 ; Only write to scalar if call24 >= 3 (i.e. not in invalid context)
85 ; Since it should be never executed otherwise, the condition is not strictly necessary. 
86 ; CHECK:          Stmt_for_body_us_preheader_i
87 ; CHECK-NEXT:            MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 1]
88 ; CHECK-NEXT:                 [call24] -> { Stmt_for_body_us_preheader_i[] -> MemRef_t_1__phi[] };
89 ; CHECK-NEXT:            new: [call24] -> { Stmt_for_body_us_preheader_i[] -> MemRef1[0, 0] : call24 >= 3 };