1 ; RUN: opt < %s -passes=bounds-checking -S | FileCheck %s
2 @array = internal global [1819 x i16] zeroinitializer, section ".bss,bss"
3 @offsets = external dso_local global [10 x i16]
6 define dso_local void @test() {
11 %_tmp819 = load i16, ptr null
12 ; CHECK: br {{.*}} %trap
13 %_tmp820 = sub nsw i16 9, %_tmp819
14 %_tmp821 = sext i16 %_tmp820 to i64
15 %_tmp822 = getelementptr [10 x i16], ptr @offsets, i16 0, i64 %_tmp821
16 %_tmp823 = load i16, ptr %_tmp822
20 %_tmp907 = zext i16 %i__7.107.0 to i64
21 %_tmp908 = getelementptr [1819 x i16], ptr @array, i16 0, i64 %_tmp907
22 store i16 0, ptr %_tmp908
23 ; CHECK: br {{.*}} %trap
24 %_tmp910 = add i16 %i__7.107.0, 1
28 %i__7.107.0 = phi i16 [ undef, %bb20 ], [ %_tmp910, %bb34 ]
29 %_tmp913 = add i16 %_tmp823, 191
30 %_tmp914 = icmp ult i16 %i__7.107.0, %_tmp913
31 br i1 %_tmp914, label %bb34, label %bb19
34 %_tmp976 = icmp slt i16 0, 10
35 br i1 %_tmp976, label %bb20, label %bb39
41 @e = dso_local local_unnamed_addr global [1 x i16] zeroinitializer, align 1
44 define dso_local void @test2() local_unnamed_addr {
46 br label %while.cond1.preheader
48 while.cond1.preheader:
49 %0 = phi i16 [ undef, %entry ], [ %inc, %while.end ]
50 %1 = load i16, ptr undef, align 1
51 ; CHECK: br {{.*}} %trap
55 %inc = add nsw i16 %0, 1
56 %arrayidx = getelementptr inbounds [1 x i16], ptr @e, i16 0, i16
58 %2 = load i16, ptr %arrayidx, align 1
60 ; CHECK-NEXT: br {{.*}} %trap
61 br i1 false, label %while.end6, label %while.cond1.preheader