1; RUN: opt -aa-pipeline=basic-aa -passes=loop-versioning -S %s | FileCheck %s 2 3%struct.foo = type { [32000 x double], [32000 x double] } 4 5@global = external global %struct.foo, align 32 6 7define void @bound_check_partially_known_1(i32 %N) { 8; CHECK-LABEL: @bound_check_partially_known_1( 9; CHECK-NEXT: loop.lver.check: 10; CHECK-NEXT: [[N_EXT:%.*]] = zext i32 [[N:%.*]] to i64 11; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr [[STRUCT_FOO:%.*]], %struct.foo* @global, i64 0, i32 0, i64 [[N_EXT]] 12; CHECK-NEXT: [[SCEVGEP1:%.*]] = bitcast double* [[SCEVGEP]] to i8* 13; CHECK-NEXT: [[TMP0:%.*]] = shl nuw nsw i64 [[N_EXT]], 1 14; CHECK-NEXT: [[SCEVGEP2:%.*]] = getelementptr [[STRUCT_FOO]], %struct.foo* @global, i64 0, i32 0, i64 [[TMP0]] 15; CHECK-NEXT: [[SCEVGEP23:%.*]] = bitcast double* [[SCEVGEP2]] to i8* 16; CHECK-NEXT: [[TMP1:%.*]] = add nuw nsw i64 [[N_EXT]], 32000 17; CHECK-NEXT: [[SCEVGEP4:%.*]] = getelementptr [[STRUCT_FOO]], %struct.foo* @global, i64 0, i32 0, i64 [[TMP1]] 18; CHECK-NEXT: [[SCEVGEP45:%.*]] = bitcast double* [[SCEVGEP4]] to i8* 19; CHECK-NEXT: [[BOUND1:%.*]] = icmp ult i8* bitcast (%struct.foo* @global to i8*), [[SCEVGEP23]] 20; CHECK-NEXT: [[BOUND06:%.*]] = icmp ult i8* [[SCEVGEP1]], [[SCEVGEP45]] 21; CHECK-NEXT: [[BOUND17:%.*]] = icmp ult i8* bitcast (double* getelementptr inbounds ([[STRUCT_FOO]], %struct.foo* @global, i64 0, i32 1, i64 0) to i8*), [[SCEVGEP23]] 22; CHECK-NEXT: [[FOUND_CONFLICT8:%.*]] = and i1 [[BOUND06]], [[BOUND17]] 23; CHECK-NEXT: br i1 [[FOUND_CONFLICT8]], label %loop.ph.lver.orig, label %loop.ph 24; 25entry: 26 %N.ext = zext i32 %N to i64 27 br label %loop 28 29loop: 30 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ] 31 %gep.0.iv = getelementptr inbounds %struct.foo, %struct.foo* @global, i64 0, i32 0, i64 %iv 32 %l.0 = load double, double* %gep.0.iv, align 8 33 %gep.1.iv = getelementptr inbounds %struct.foo, %struct.foo* @global, i64 0, i32 1, i64 %iv 34 %l.1 = load double, double* %gep.1.iv, align 8 35 %add = fadd double %l.0, %l.1 36 %iv.N = add nuw nsw i64 %iv, %N.ext 37 %gep.0.iv.N = getelementptr inbounds %struct.foo, %struct.foo* @global, i64 0, i32 0, i64 %iv.N 38 store double %add, double* %gep.0.iv.N, align 8 39 %iv.next = add nuw nsw i64 %iv, 1 40 %exitcond = icmp eq i64 %iv.next, %N.ext 41 br i1 %exitcond, label %exit, label %loop 42 43exit: 44 ret void 45} 46