1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=instcombine %s -o - | FileCheck %s
4 ; All the "useless" instructions should be removed and we shouldn't crash.
6 target datalayout = "p:16:16"
10 @a = external global i16
11 @b = external global ptr
13 define void @f(i1 %cond) {
16 ; CHECK-NEXT: [[T1:%.*]] = alloca i64, align 8
17 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[BB1:%.*]], label [[BB2:%.*]]
19 ; CHECK-NEXT: unreachable
21 ; CHECK-NEXT: [[T9:%.*]] = load ptr, ptr @b, align 2
22 ; CHECK-NEXT: store i16 0, ptr [[T9]], align 2
23 ; CHECK-NEXT: [[T10:%.*]] = load i32, ptr [[T1]], align 4
24 ; CHECK-NEXT: [[T11:%.*]] = add i32 [[T10]], -1
25 ; CHECK-NEXT: store i32 [[T11]], ptr [[T1]], align 4
26 ; CHECK-NEXT: ret void
30 %useless4 = getelementptr inbounds i16, ptr %t1, i16 undef
31 br i1 %cond, label %bb1, label %bb2
34 %useless6 = insertvalue [1 x ptr] undef, ptr %t1, 0
35 %useless7 = insertvalue [1 x ptr] %useless6, ptr null, 0
36 %t8 = ptrtoint ptr %t1 to i16
41 %t9 = load ptr, ptr @b
43 %t10 = load i32, ptr %t1
44 %t11 = sub i32 %t10, 1
45 store i32 %t11, ptr %t1