1; RUN: opt -basic-aa -loop-versioning -S < %s | FileCheck %s 2target triple = "x86_64-unknown-linux-gnu" 3 4define void @fill(i8** %ls1.20, i8** %ls2.21, i8* %cse3.22) { 5; CHECK-LABEL: @fill( 6; CHECK-NEXT: bb1.lver.check: 7; CHECK-NEXT: [[LS1_20_PROMOTED:%.*]] = load i8*, i8** [[LS1_20:%.*]], align 8 8; CHECK-NEXT: [[LS2_21_PROMOTED:%.*]] = load i8*, i8** [[LS2_21:%.*]], align 8 9; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, i8* [[LS1_20_PROMOTED]], i64 -1 10; CHECK-NEXT: [[SCEVGEP1:%.*]] = getelementptr i8, i8* [[LS1_20_PROMOTED]], i64 1 11; CHECK-NEXT: [[SCEVGEP2:%.*]] = getelementptr i8, i8* [[LS2_21_PROMOTED]], i64 1 12; CHECK-NEXT: [[BOUND0:%.*]] = icmp ult i8* [[SCEVGEP]], [[SCEVGEP2]] 13; CHECK-NEXT: [[BOUND1:%.*]] = icmp ult i8* [[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: 17; 18bb1.ph: 19 %ls1.20.promoted = load i8*, i8** %ls1.20 20 %ls2.21.promoted = load i8*, i8** %ls2.21 21 br label %bb1 22 23bb1: 24 %_tmp302 = phi i8* [ %ls2.21.promoted, %bb1.ph ], [ %_tmp30, %bb1 ] 25 %_tmp281 = phi i8* [ %ls1.20.promoted, %bb1.ph ], [ %_tmp28, %bb1 ] 26 %_tmp14 = getelementptr i8, i8* %_tmp281, i16 -1 27 %_tmp15 = load i8, i8* %_tmp14 28 %add = add i8 %_tmp15, 1 29 store i8 %add, i8* %_tmp281 30 store i8 %add, i8* %_tmp302 31 %_tmp28 = getelementptr i8, i8* %_tmp281, i16 1 32 %_tmp30 = getelementptr i8, i8* %_tmp302, i16 1 33 br i1 false, label %bb1, label %bb3.loopexit 34 35bb3.loopexit: 36 %_tmp30.lcssa = phi i8* [ %_tmp30, %bb1 ] 37 %_tmp15.lcssa = phi i8 [ %_tmp15, %bb1 ] 38 %_tmp28.lcssa = phi i8* [ %_tmp28, %bb1 ] 39 store i8* %_tmp28.lcssa, i8** %ls1.20 40 store i8 %_tmp15.lcssa, i8* %cse3.22 41 store i8* %_tmp30.lcssa, i8** %ls2.21 42 br label %bb3 43 44bb3: 45 ret void 46} 47 48define void @fill_no_null_opt(i8** %ls1.20, i8** %ls2.21, i8* %cse3.22) #0 { 49; CHECK-LABEL: @fill_no_null_opt( 50; CHECK-NEXT: bb1.lver.check: 51; CHECK-NEXT: [[LS1_20_PROMOTED:%.*]] = load i8*, i8** [[LS1_20:%.*]], align 8 52; CHECK-NEXT: [[LS2_21_PROMOTED:%.*]] = load i8*, i8** [[LS2_21:%.*]], align 8 53; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, i8* [[LS1_20_PROMOTED]], i64 -1 54; CHECK-NEXT: [[SCEVGEP1:%.*]] = getelementptr i8, i8* [[LS1_20_PROMOTED]], i64 1 55; CHECK-NEXT: [[SCEVGEP2:%.*]] = getelementptr i8, i8* [[LS2_21_PROMOTED]], i64 1 56; CHECK-NEXT: [[BOUND0:%.*]] = icmp ult i8* [[SCEVGEP]], [[SCEVGEP2]] 57; CHECK-NEXT: [[BOUND1:%.*]] = icmp ult i8* [[LS2_21_PROMOTED]], [[SCEVGEP1]] 58; CHECK-NEXT: [[FOUND_CONFLICT:%.*]] = and i1 [[BOUND0]], [[BOUND1]] 59; CHECK-NEXT: [[SCEVGEP3:%.*]] = getelementptr i8, i8* [[LS1_20_PROMOTED]], i64 -1 60; CHECK-NEXT: br i1 [[FOUND_CONFLICT]], label %bb1.ph.lver.orig, label %bb1.ph 61; CHECK: bb1.ph.lver.orig: 62; 63bb1.ph: 64 %ls1.20.promoted = load i8*, i8** %ls1.20 65 %ls2.21.promoted = load i8*, i8** %ls2.21 66 br label %bb1 67 68bb1: 69 %_tmp302 = phi i8* [ %ls2.21.promoted, %bb1.ph ], [ %_tmp30, %bb1 ] 70 %_tmp281 = phi i8* [ %ls1.20.promoted, %bb1.ph ], [ %_tmp28, %bb1 ] 71 %_tmp14 = getelementptr i8, i8* %_tmp281, i16 -1 72 %_tmp15 = load i8, i8* %_tmp14 73 %add = add i8 %_tmp15, 1 74 store i8 %add, i8* %_tmp281 75 store i8 %add, i8* %_tmp302 76 %_tmp28 = getelementptr i8, i8* %_tmp281, i16 1 77 %_tmp30 = getelementptr i8, i8* %_tmp302, i16 1 78 br i1 false, label %bb1, label %bb3.loopexit 79 80bb3.loopexit: 81 %_tmp30.lcssa = phi i8* [ %_tmp30, %bb1 ] 82 %_tmp15.lcssa = phi i8 [ %_tmp15, %bb1 ] 83 %_tmp28.lcssa = phi i8* [ %_tmp28, %bb1 ] 84 store i8* %_tmp28.lcssa, i8** %ls1.20 85 store i8 %_tmp15.lcssa, i8* %cse3.22 86 store i8* %_tmp30.lcssa, i8** %ls2.21 87 br label %bb3 88 89bb3: 90 ret void 91} 92 93attributes #0 = { null_pointer_is_valid } 94