]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/Transforms/NewGVN/memory-handling.ll
Vendor import of llvm trunk r351319 (just before the release_80 branch
[FreeBSD/FreeBSD.git] / test / Transforms / NewGVN / memory-handling.ll
1 ;; This test is really dependent on propagating a lot of memory info around, but in the end, not
2 ;; screwing up a single add.
3 ; RUN: opt < %s -basicaa -newgvn -S | FileCheck %s
4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5
6 %struct.Letter = type { i32, i32, i32, i32 }
7
8 @alPhrase = external local_unnamed_addr global [26 x %struct.Letter], align 16
9 @aqMainMask = external local_unnamed_addr global [2 x i64], align 16
10 @aqMainSign = external local_unnamed_addr global [2 x i64], align 16
11 @cchPhraseLength = external local_unnamed_addr global i32, align 4
12 @auGlobalFrequency = external local_unnamed_addr global [26 x i32], align 16
13 @.str.7 = external hidden unnamed_addr constant [28 x i8], align 1
14
15 ; Function Attrs: nounwind uwtable
16 declare void @Fatal(i8*, i32) local_unnamed_addr #0
17
18 ; Function Attrs: nounwind readnone
19 declare i16** @__ctype_b_loc() local_unnamed_addr #1
20
21 ; Function Attrs: nounwind uwtable
22 define void @BuildMask(i8* nocapture readonly) local_unnamed_addr #0 {
23   tail call void @llvm.memset.p0i8.i64(i8* align 16 bitcast ([26 x %struct.Letter]* @alPhrase to i8*), i8 0, i64 416, i1 false)
24   tail call void @llvm.memset.p0i8.i64(i8* align 16 bitcast ([2 x i64]* @aqMainMask to i8*), i8 0, i64 16, i1 false)
25   tail call void @llvm.memset.p0i8.i64(i8* align 16 bitcast ([2 x i64]* @aqMainSign to i8*), i8 0, i64 16, i1 false)
26   br label %.sink.split
27
28 .sink.split:                                      ; preds = %14, %1
29   %.0 = phi i8* [ %0, %1 ], [ %.lcssa67, %14 ]
30   %.sink = phi i32 [ 0, %1 ], [ %23, %14 ]
31   store i32 %.sink, i32* @cchPhraseLength, align 4, !tbaa !1
32   br label %2
33
34 ; <label>:2:                                      ; preds = %6, %.sink.split
35   %.1 = phi i8* [ %.0, %.sink.split ], [ %3, %6 ]
36   %3 = getelementptr inbounds i8, i8* %.1, i64 1
37   %4 = load i8, i8* %.1, align 1, !tbaa !5
38   %5 = icmp eq i8 %4, 0
39   br i1 %5, label %.preheader.preheader, label %6
40
41 .preheader.preheader:                             ; preds = %2
42   br label %.preheader
43
44 ; <label>:6:                                      ; preds = %2
45   %7 = tail call i16** @__ctype_b_loc() #4
46   %8 = load i16*, i16** %7, align 8, !tbaa !6
47   %9 = sext i8 %4 to i64
48   %10 = getelementptr inbounds i16, i16* %8, i64 %9
49   %11 = load i16, i16* %10, align 2, !tbaa !8
50   %12 = and i16 %11, 1024
51   %13 = icmp eq i16 %12, 0
52   br i1 %13, label %2, label %14
53
54 ; <label>:14:                                     ; preds = %6
55   %.lcssa67 = phi i8* [ %3, %6 ]
56   %.lcssa65 = phi i8 [ %4, %6 ]
57   %15 = sext i8 %.lcssa65 to i32
58   %16 = tail call i32 @tolower(i32 %15) #5
59   %17 = add nsw i32 %16, -97
60   %18 = sext i32 %17 to i64
61   %19 = getelementptr inbounds [26 x %struct.Letter], [26 x %struct.Letter]* @alPhrase, i64 0, i64 %18, i32 0
62   %20 = load i32, i32* %19, align 16, !tbaa !10
63   %21 = add i32 %20, 1
64   store i32 %21, i32* %19, align 16, !tbaa !10
65   %22 = load i32, i32* @cchPhraseLength, align 4, !tbaa !1
66   %23 = add nsw i32 %22, 1
67   br label %.sink.split
68
69 .preheader:                                       ; preds = %58, %.preheader.preheader
70   %indvars.iv = phi i64 [ 0, %.preheader.preheader ], [ %indvars.iv.next, %58 ]
71   %.04961 = phi i32 [ %.2, %58 ], [ 0, %.preheader.preheader ]
72   %.05160 = phi i32 [ %.253, %58 ], [ 0, %.preheader.preheader ]
73   %24 = getelementptr inbounds [26 x %struct.Letter], [26 x %struct.Letter]* @alPhrase, i64 0, i64 %indvars.iv, i32 0
74   %25 = load i32, i32* %24, align 16, !tbaa !10
75   %26 = icmp eq i32 %25, 0
76   %27 = getelementptr inbounds [26 x i32], [26 x i32]* @auGlobalFrequency, i64 0, i64 %indvars.iv
77   br i1 %26, label %28, label %29
78
79 ; <label>:28:                                     ; preds = %.preheader
80   store i32 -1, i32* %27, align 4, !tbaa !1
81   br label %58
82
83 ; <label>:29:                                     ; preds = %.preheader
84   store i32 0, i32* %27, align 4, !tbaa !1
85   %30 = zext i32 %25 to i64
86   br i1 false, label %._crit_edge, label %.lr.ph.preheader
87
88 .lr.ph.preheader:                                 ; preds = %29
89   br label %.lr.ph
90
91 .lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader
92   %.04658 = phi i64 [ %32, %.lr.ph ], [ 1, %.lr.ph.preheader ]
93   %.04857 = phi i32 [ %31, %.lr.ph ], [ 1, %.lr.ph.preheader ]
94   %31 = add nuw nsw i32 %.04857, 1
95   %32 = shl i64 %.04658, 1
96   %33 = icmp ult i64 %30, %32
97   br i1 %33, label %._crit_edge.loopexit, label %.lr.ph
98
99 ._crit_edge.loopexit:                             ; preds = %.lr.ph
100   %.lcssa63 = phi i32 [ %31, %.lr.ph ]
101   %.lcssa = phi i64 [ %32, %.lr.ph ]
102   br label %._crit_edge
103
104 ._crit_edge:                                      ; preds = %._crit_edge.loopexit, %29
105   %.048.lcssa = phi i32 [ 1, %29 ], [ %.lcssa63, %._crit_edge.loopexit ]
106   %.046.lcssa = phi i64 [ 1, %29 ], [ %.lcssa, %._crit_edge.loopexit ]
107   %34 = add nsw i32 %.048.lcssa, %.04961
108   %35 = icmp ugt i32 %34, 64
109   br i1 %35, label %36, label %40
110
111 ; <label>:36:                                     ; preds = %._crit_edge
112 ; This testcase essentially comes down to this little add.
113 ; If we screw up the revisitation of the users of store of %sink above
114 ; we will end up propagating and simplifying this to 1 in the final output
115 ; because we keep an optimistic assumption we should not.
116 ; CHECK:  add i32 %.05160, 1
117   %37 = add i32 %.05160, 1
118   %38 = icmp ugt i32 %37, 1
119   br i1 %38, label %39, label %40
120
121 ; <label>:39:                                     ; preds = %36
122   tail call void @Fatal(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i32 0)
123   br label %40
124
125 ; <label>:40:                                     ; preds = %39, %36, %._crit_edge
126   %.152 = phi i32 [ %.05160, %._crit_edge ], [ %37, %39 ], [ %37, %36 ]
127   %.150 = phi i32 [ %.04961, %._crit_edge ], [ 0, %39 ], [ 0, %36 ]
128   %41 = add i64 %.046.lcssa, 4294967295
129   %42 = trunc i64 %41 to i32
130   %43 = getelementptr inbounds [26 x %struct.Letter], [26 x %struct.Letter]* @alPhrase, i64 0, i64 %indvars.iv, i32 2
131   store i32 %42, i32* %43, align 8, !tbaa !12
132   %44 = zext i32 %.150 to i64
133   %.046. = shl i64 %.046.lcssa, %44
134   %45 = zext i32 %.152 to i64
135   %46 = getelementptr inbounds [2 x i64], [2 x i64]* @aqMainSign, i64 0, i64 %45
136   %47 = load i64, i64* %46, align 8, !tbaa !13
137   %48 = or i64 %47, %.046.
138   store i64 %48, i64* %46, align 8, !tbaa !13
139   %49 = load i32, i32* %24, align 16, !tbaa !10
140   %50 = zext i32 %49 to i64
141   %51 = shl i64 %50, %44
142   %52 = getelementptr inbounds [2 x i64], [2 x i64]* @aqMainMask, i64 0, i64 %45
143   %53 = load i64, i64* %52, align 8, !tbaa !13
144   %54 = or i64 %51, %53
145   store i64 %54, i64* %52, align 8, !tbaa !13
146   %55 = getelementptr inbounds [26 x %struct.Letter], [26 x %struct.Letter]* @alPhrase, i64 0, i64 %indvars.iv, i32 1
147   store i32 %.150, i32* %55, align 4, !tbaa !15
148   %56 = getelementptr inbounds [26 x %struct.Letter], [26 x %struct.Letter]* @alPhrase, i64 0, i64 %indvars.iv, i32 3
149   store i32 %.152, i32* %56, align 4, !tbaa !16
150   %57 = add nsw i32 %.150, %.048.lcssa
151   br label %58
152
153 ; <label>:58:                                     ; preds = %40, %28
154   %.253 = phi i32 [ %.05160, %28 ], [ %.152, %40 ]
155   %.2 = phi i32 [ %.04961, %28 ], [ %57, %40 ]
156   %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
157   %exitcond = icmp ne i64 %indvars.iv.next, 26
158   br i1 %exitcond, label %.preheader, label %59
159
160 ; <label>:59:                                     ; preds = %58
161   ret void
162 }
163
164 ; Function Attrs: argmemonly nounwind
165 declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i1) #2
166
167 ; Function Attrs: inlinehint nounwind readonly uwtable
168 declare i32 @tolower(i32) local_unnamed_addr #3
169
170 attributes #0 = { nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
171 attributes #1 = { nounwind readnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
172 attributes #2 = { argmemonly nounwind }
173 attributes #3 = { inlinehint nounwind readonly uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
174 attributes #4 = { nounwind readnone }
175 attributes #5 = { nounwind readonly }
176
177 !llvm.ident = !{!0}
178
179 !0 = !{!"clang version 4.0.0"}
180 !1 = !{!2, !2, i64 0}
181 !2 = !{!"int", !3, i64 0}
182 !3 = !{!"omnipotent char", !4, i64 0}
183 !4 = !{!"Simple C/C++ TBAA"}
184 !5 = !{!3, !3, i64 0}
185 !6 = !{!7, !7, i64 0}
186 !7 = !{!"any pointer", !3, i64 0}
187 !8 = !{!9, !9, i64 0}
188 !9 = !{!"short", !3, i64 0}
189 !10 = !{!11, !2, i64 0}
190 !11 = !{!"", !2, i64 0, !2, i64 4, !2, i64 8, !2, i64 12}
191 !12 = !{!11, !2, i64 8}
192 !13 = !{!14, !14, i64 0}
193 !14 = !{!"long", !3, i64 0}
194 !15 = !{!11, !2, i64 4}
195 !16 = !{!11, !2, i64 12}