llvm.org GIT mirror llvm / 3e55e45
Add original reproducer for r307754 / PR33689 Apparently I managed to drop the test case between two revisions in Phabricator: https://reviews.llvm.org/D35003 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307887 91177308-0d34-0410-b5e6-96231b3b80d8 Mikael Holmen 3 years ago
1 changed file(s) with 53 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
1 ; RUN: opt -S -instcombine %s -o - | FileCheck %s
2
3 ; All the "useless" instructions should be removed and we shouldn't crash.
4
5 target datalayout = "p:16:16"
6
7 %i64_t = type i64
8
9 @a = external global i16
10 @b = external global i16*
11
12 define void @f() {
13 ; CHECK-LABEL: @f(
14 ; CHECK-NEXT: bb0:
15 ; CHECK-NEXT: [[TMP12:%.*]] = alloca [2 x i32], align 8
16 ; CHECK-NEXT: [[TMP12_SUB:%.*]] = getelementptr inbounds [2 x i32], [2 x i32]* [[TMP12]], i16 0, i16 0
17 ; CHECK-NEXT: br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]]
18 ; CHECK: bb1:
19 ; CHECK-NEXT: [[TMP8:%.*]] = ptrtoint [2 x i32]* [[TMP12]] to i16
20 ; CHECK-NEXT: store i16 [[TMP8]], i16* @a, align 2
21 ; CHECK-NEXT: unreachable
22 ; CHECK: bb2:
23 ; CHECK-NEXT: [[TMP9:%.*]] = load i16*, i16** @b, align 2
24 ; CHECK-NEXT: store i16 0, i16* [[TMP9]], align 2
25 ; CHECK-NEXT: [[TMP10:%.*]] = load i32, i32* [[TMP12_SUB]], align 8
26 ; CHECK-NEXT: [[TMP11:%.*]] = add i32 [[TMP10]], -1
27 ; CHECK-NEXT: store i32 [[TMP11]], i32* [[TMP12_SUB]], align 8
28 ; CHECK-NEXT: ret void
29 ;
30 bb0:
31 %tmp1 = alloca %i64_t
32 %tmp2 = bitcast %i64_t* %tmp1 to i32*
33 %useless3 = bitcast %i64_t* %tmp1 to i16*
34 %useless4 = getelementptr inbounds i16, i16* %useless3, i16 undef
35 %useless5 = bitcast i16* %useless4 to i32*
36 br i1 undef, label %bb1, label %bb2
37
38 bb1: ; preds = %bb0
39 %useless6 = insertvalue [1 x i32*] undef, i32* %tmp2, 0
40 %useless7 = insertvalue [1 x i32*] %useless6, i32* null, 0
41 %tmp8 = ptrtoint i32* %tmp2 to i16
42 store i16 %tmp8, i16* @a
43 unreachable
44
45 bb2: ; preds = %bb0
46 %tmp9 = load i16*, i16** @b
47 store i16 0, i16* %tmp9
48 %tmp10 = load i32, i32* %tmp2
49 %tmp11 = sub i32 %tmp10, 1
50 store i32 %tmp11, i32* %tmp2
51 ret void
52 }