1 ; RUN: opt -passes=loop-versioning -S < %s | FileCheck %s
2 target triple = "x86_64-unknown-linux-gnu"
4 define void @fill(ptr %ls1.20, ptr %ls2.21, ptr %cse3.22) {
6 ; CHECK-NEXT: bb1.lver.check:
7 ; CHECK-NEXT: [[LS1_20_PROMOTED:%.*]] = load ptr, ptr [[LS1_20:%.*]], align 8
8 ; CHECK-NEXT: [[LS2_21_PROMOTED:%.*]] = load ptr, ptr [[LS2_21:%.*]], align 8
9 ; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, ptr [[LS1_20_PROMOTED]], i64 -1
10 ; CHECK-NEXT: [[SCEVGEP1:%.*]] = getelementptr i8, ptr [[LS1_20_PROMOTED]], i64 1
11 ; CHECK-NEXT: [[SCEVGEP2:%.*]] = getelementptr i8, ptr [[LS2_21_PROMOTED]], i64 1
12 ; CHECK-NEXT: [[BOUND0:%.*]] = icmp ult ptr [[SCEVGEP]], [[SCEVGEP2]]
13 ; CHECK-NEXT: [[BOUND1:%.*]] = icmp ult ptr [[LS2_21_PROMOTED]], [[SCEVGEP1]]
14 ; CHECK-NEXT: [[FOUND_CONFLICT:%.*]] = and i1 [[BOUND0]], [[BOUND1]]
15 ; CHECK-NEXT: br i1 [[FOUND_CONFLICT]], label %bb1.ph.lver.orig, label %bb1.ph
16 ; CHECK: bb1.ph.lver.orig:
19 %ls1.20.promoted = load ptr, ptr %ls1.20
20 %ls2.21.promoted = load ptr, ptr %ls2.21
24 %_tmp302 = phi ptr [ %ls2.21.promoted, %bb1.ph ], [ %_tmp30, %bb1 ]
25 %_tmp281 = phi ptr [ %ls1.20.promoted, %bb1.ph ], [ %_tmp28, %bb1 ]
26 %_tmp14 = getelementptr i8, ptr %_tmp281, i16 -1
27 %_tmp15 = load i8, ptr %_tmp14
28 %add = add i8 %_tmp15, 1
29 store i8 %add, ptr %_tmp281
30 store i8 %add, ptr %_tmp302
31 %_tmp28 = getelementptr i8, ptr %_tmp281, i16 1
32 %_tmp30 = getelementptr i8, ptr %_tmp302, i16 1
33 br i1 false, label %bb1, label %bb3.loopexit
36 %_tmp30.lcssa = phi ptr [ %_tmp30, %bb1 ]
37 %_tmp15.lcssa = phi i8 [ %_tmp15, %bb1 ]
38 %_tmp28.lcssa = phi ptr [ %_tmp28, %bb1 ]
39 store ptr %_tmp28.lcssa, ptr %ls1.20
40 store i8 %_tmp15.lcssa, ptr %cse3.22
41 store ptr %_tmp30.lcssa, ptr %ls2.21
48 define void @fill_no_null_opt(ptr %ls1.20, ptr %ls2.21, ptr %cse3.22) #0 {
49 ; CHECK-LABEL: @fill_no_null_opt(
50 ; CHECK-NEXT: bb1.lver.check:
51 ; CHECK-NEXT: [[LS1_20_PROMOTED:%.*]] = load ptr, ptr [[LS1_20:%.*]], align 8
52 ; CHECK-NEXT: [[LS2_21_PROMOTED:%.*]] = load ptr, ptr [[LS2_21:%.*]], align 8
53 ; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, ptr [[LS1_20_PROMOTED]], i64 -1
54 ; CHECK-NEXT: [[SCEVGEP1:%.*]] = getelementptr i8, ptr [[LS1_20_PROMOTED]], i64 1
55 ; CHECK-NEXT: [[SCEVGEP2:%.*]] = getelementptr i8, ptr [[LS2_21_PROMOTED]], i64 1
56 ; CHECK-NEXT: [[BOUND0:%.*]] = icmp ult ptr [[SCEVGEP]], [[SCEVGEP2]]
57 ; CHECK-NEXT: [[BOUND1:%.*]] = icmp ult ptr [[LS2_21_PROMOTED]], [[SCEVGEP1]]
58 ; CHECK-NEXT: [[FOUND_CONFLICT:%.*]] = and i1 [[BOUND0]], [[BOUND1]]
59 ; CHECK-NEXT: br i1 [[FOUND_CONFLICT]], label %bb1.ph.lver.orig, label %bb1.ph
60 ; CHECK: bb1.ph.lver.orig:
63 %ls1.20.promoted = load ptr, ptr %ls1.20
64 %ls2.21.promoted = load ptr, ptr %ls2.21
68 %_tmp302 = phi ptr [ %ls2.21.promoted, %bb1.ph ], [ %_tmp30, %bb1 ]
69 %_tmp281 = phi ptr [ %ls1.20.promoted, %bb1.ph ], [ %_tmp28, %bb1 ]
70 %_tmp14 = getelementptr i8, ptr %_tmp281, i16 -1
71 %_tmp15 = load i8, ptr %_tmp14
72 %add = add i8 %_tmp15, 1
73 store i8 %add, ptr %_tmp281
74 store i8 %add, ptr %_tmp302
75 %_tmp28 = getelementptr i8, ptr %_tmp281, i16 1
76 %_tmp30 = getelementptr i8, ptr %_tmp302, i16 1
77 br i1 false, label %bb1, label %bb3.loopexit
80 %_tmp30.lcssa = phi ptr [ %_tmp30, %bb1 ]
81 %_tmp15.lcssa = phi i8 [ %_tmp15, %bb1 ]
82 %_tmp28.lcssa = phi ptr [ %_tmp28, %bb1 ]
83 store ptr %_tmp28.lcssa, ptr %ls1.20
84 store i8 %_tmp15.lcssa, ptr %cse3.22
85 store ptr %_tmp30.lcssa, ptr %ls2.21
92 attributes #0 = { null_pointer_is_valid }