1f31811f2SFangrui Song; RUN: opt -basic-aa -loop-versioning -S < %s | FileCheck %s
2cee313d2SEric Christophertarget triple = "x86_64-unknown-linux-gnu"
3cee313d2SEric Christopher
4cee313d2SEric Christopherdefine void @fill(i8** %ls1.20, i8** %ls2.21, i8* %cse3.22) {
54a42ce25SFlorian Hahn; CHECK-LABEL: @fill(
64a42ce25SFlorian Hahn; CHECK-NEXT:  bb1.lver.check:
74a42ce25SFlorian Hahn; CHECK-NEXT:    [[LS1_20_PROMOTED:%.*]] = load i8*, i8** [[LS1_20:%.*]], align 8
84a42ce25SFlorian Hahn; CHECK-NEXT:    [[LS2_21_PROMOTED:%.*]] = load i8*, i8** [[LS2_21:%.*]], align 8
94a42ce25SFlorian Hahn; CHECK-NEXT:    [[SCEVGEP:%.*]] = getelementptr i8, i8* [[LS1_20_PROMOTED]], i64 -1
104a42ce25SFlorian Hahn; CHECK-NEXT:    [[SCEVGEP1:%.*]] = getelementptr i8, i8* [[LS1_20_PROMOTED]], i64 1
114a42ce25SFlorian Hahn; CHECK-NEXT:    [[SCEVGEP2:%.*]] = getelementptr i8, i8* [[LS2_21_PROMOTED]], i64 1
124a42ce25SFlorian Hahn; CHECK-NEXT:    [[BOUND0:%.*]] = icmp ult i8* [[SCEVGEP]], [[SCEVGEP2]]
134a42ce25SFlorian Hahn; CHECK-NEXT:    [[BOUND1:%.*]] = icmp ult i8* [[LS2_21_PROMOTED]], [[SCEVGEP1]]
144a42ce25SFlorian Hahn; CHECK-NEXT:    [[FOUND_CONFLICT:%.*]] = and i1 [[BOUND0]], [[BOUND1]]
154a42ce25SFlorian Hahn; CHECK-NEXT:    br i1 [[FOUND_CONFLICT]], label %bb1.ph.lver.orig, label %bb1.ph
164a42ce25SFlorian Hahn; CHECK:       bb1.ph.lver.orig:
174a42ce25SFlorian Hahn;
18cee313d2SEric Christopherbb1.ph:
19cee313d2SEric Christopher  %ls1.20.promoted = load i8*, i8** %ls1.20
20cee313d2SEric Christopher  %ls2.21.promoted = load i8*, i8** %ls2.21
21cee313d2SEric Christopher  br label %bb1
22cee313d2SEric Christopher
23cee313d2SEric Christopherbb1:
24cee313d2SEric Christopher  %_tmp302 = phi i8* [ %ls2.21.promoted, %bb1.ph ], [ %_tmp30, %bb1 ]
25cee313d2SEric Christopher  %_tmp281 = phi i8* [ %ls1.20.promoted, %bb1.ph ], [ %_tmp28, %bb1 ]
26cee313d2SEric Christopher  %_tmp14 = getelementptr i8, i8* %_tmp281, i16 -1
27cee313d2SEric Christopher  %_tmp15 = load i8, i8* %_tmp14
28cee313d2SEric Christopher  %add = add i8 %_tmp15, 1
29cee313d2SEric Christopher  store i8 %add, i8* %_tmp281
30cee313d2SEric Christopher  store i8 %add, i8* %_tmp302
31cee313d2SEric Christopher  %_tmp28 = getelementptr i8, i8* %_tmp281, i16 1
32cee313d2SEric Christopher  %_tmp30 = getelementptr i8, i8* %_tmp302, i16 1
33cee313d2SEric Christopher  br i1 false, label %bb1, label %bb3.loopexit
34cee313d2SEric Christopher
35cee313d2SEric Christopherbb3.loopexit:
36cee313d2SEric Christopher  %_tmp30.lcssa = phi i8* [ %_tmp30, %bb1 ]
37cee313d2SEric Christopher  %_tmp15.lcssa = phi i8 [ %_tmp15, %bb1 ]
38cee313d2SEric Christopher  %_tmp28.lcssa = phi i8* [ %_tmp28, %bb1 ]
39cee313d2SEric Christopher  store i8* %_tmp28.lcssa, i8** %ls1.20
40cee313d2SEric Christopher  store i8 %_tmp15.lcssa, i8* %cse3.22
41cee313d2SEric Christopher  store i8* %_tmp30.lcssa, i8** %ls2.21
42cee313d2SEric Christopher  br label %bb3
43cee313d2SEric Christopher
44cee313d2SEric Christopherbb3:
45cee313d2SEric Christopher  ret void
46cee313d2SEric Christopher}
47cee313d2SEric Christopher
48cee313d2SEric Christopherdefine void @fill_no_null_opt(i8** %ls1.20, i8** %ls2.21, i8* %cse3.22) #0 {
494a42ce25SFlorian Hahn; CHECK-LABEL: @fill_no_null_opt(
504a42ce25SFlorian Hahn; CHECK-NEXT:  bb1.lver.check:
514a42ce25SFlorian Hahn; CHECK-NEXT:    [[LS1_20_PROMOTED:%.*]] = load i8*, i8** [[LS1_20:%.*]], align 8
524a42ce25SFlorian Hahn; CHECK-NEXT:    [[LS2_21_PROMOTED:%.*]] = load i8*, i8** [[LS2_21:%.*]], align 8
534a42ce25SFlorian Hahn; CHECK-NEXT:    [[SCEVGEP:%.*]] = getelementptr i8, i8* [[LS1_20_PROMOTED]], i64 -1
544a42ce25SFlorian Hahn; CHECK-NEXT:    [[SCEVGEP1:%.*]] = getelementptr i8, i8* [[LS1_20_PROMOTED]], i64 1
554a42ce25SFlorian Hahn; CHECK-NEXT:    [[SCEVGEP2:%.*]] = getelementptr i8, i8* [[LS2_21_PROMOTED]], i64 1
564a42ce25SFlorian Hahn; CHECK-NEXT:    [[BOUND0:%.*]] = icmp ult i8* [[SCEVGEP]], [[SCEVGEP2]]
574a42ce25SFlorian Hahn; CHECK-NEXT:    [[BOUND1:%.*]] = icmp ult i8* [[LS2_21_PROMOTED]], [[SCEVGEP1]]
584a42ce25SFlorian Hahn; CHECK-NEXT:    [[FOUND_CONFLICT:%.*]] = and i1 [[BOUND0]], [[BOUND1]]
594a42ce25SFlorian Hahn; CHECK-NEXT:    [[SCEVGEP3:%.*]] = getelementptr i8, i8* [[LS1_20_PROMOTED]], i64 -1
60*138fcc5fSFlorian Hahn; CHECK-NEXT:    br i1 [[FOUND_CONFLICT]], label %bb1.ph.lver.orig, label %bb1.ph
614a42ce25SFlorian Hahn; CHECK:       bb1.ph.lver.orig:
624a42ce25SFlorian Hahn;
63cee313d2SEric Christopherbb1.ph:
64cee313d2SEric Christopher  %ls1.20.promoted = load i8*, i8** %ls1.20
65cee313d2SEric Christopher  %ls2.21.promoted = load i8*, i8** %ls2.21
66cee313d2SEric Christopher  br label %bb1
67cee313d2SEric Christopher
68cee313d2SEric Christopherbb1:
69cee313d2SEric Christopher  %_tmp302 = phi i8* [ %ls2.21.promoted, %bb1.ph ], [ %_tmp30, %bb1 ]
70cee313d2SEric Christopher  %_tmp281 = phi i8* [ %ls1.20.promoted, %bb1.ph ], [ %_tmp28, %bb1 ]
71cee313d2SEric Christopher  %_tmp14 = getelementptr i8, i8* %_tmp281, i16 -1
72cee313d2SEric Christopher  %_tmp15 = load i8, i8* %_tmp14
73cee313d2SEric Christopher  %add = add i8 %_tmp15, 1
74cee313d2SEric Christopher  store i8 %add, i8* %_tmp281
75cee313d2SEric Christopher  store i8 %add, i8* %_tmp302
76cee313d2SEric Christopher  %_tmp28 = getelementptr i8, i8* %_tmp281, i16 1
77cee313d2SEric Christopher  %_tmp30 = getelementptr i8, i8* %_tmp302, i16 1
78cee313d2SEric Christopher  br i1 false, label %bb1, label %bb3.loopexit
79cee313d2SEric Christopher
80cee313d2SEric Christopherbb3.loopexit:
81cee313d2SEric Christopher  %_tmp30.lcssa = phi i8* [ %_tmp30, %bb1 ]
82cee313d2SEric Christopher  %_tmp15.lcssa = phi i8 [ %_tmp15, %bb1 ]
83cee313d2SEric Christopher  %_tmp28.lcssa = phi i8* [ %_tmp28, %bb1 ]
84cee313d2SEric Christopher  store i8* %_tmp28.lcssa, i8** %ls1.20
85cee313d2SEric Christopher  store i8 %_tmp15.lcssa, i8* %cse3.22
86cee313d2SEric Christopher  store i8* %_tmp30.lcssa, i8** %ls2.21
87cee313d2SEric Christopher  br label %bb3
88cee313d2SEric Christopher
89cee313d2SEric Christopherbb3:
90cee313d2SEric Christopher  ret void
91cee313d2SEric Christopher}
92cee313d2SEric Christopher
93f89f7da9SNikita Popovattributes #0 = { null_pointer_is_valid }
94