1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -S -instcombine -instcombine-infinite-loop-threshold=2 < %s | FileCheck %s
3
4; This used to require 10 instcombine iterations to fully optimize.
5; The number of iterations grew linearly with the number of DSEd stores,
6; resulting in overall quadratic runtime.
7
8%struct.S3 = type { i64 }
9
10@csmith_sink_ = dso_local global i64 0, align 1
11@g_302_7 = internal constant i32 0, align 1
12@g_313_0 = internal global i16 0, align 1
13@g_313_1 = internal global i32 0, align 1
14@g_313_2 = internal global i32 0, align 1
15@g_313_3 = internal global i32 0, align 1
16@g_313_4 = internal global i16 0, align 1
17@g_313_5 = internal global i16 0, align 1
18@g_313_6 = internal global i16 0, align 1
19@g_316 = internal global %struct.S3 zeroinitializer, align 1
20@g_316_1_0 = internal global i16 0, align 1
21
22define i16 @main() {
23; CHECK-LABEL: @main(
24; CHECK-NEXT:  entry:
25; CHECK-NEXT:    store i64 0, i64* @csmith_sink_, align 8
26; CHECK-NEXT:    ret i16 0
27;
28entry:
29  store i64 0, i64* @csmith_sink_, align 1
30  %0 = load i16, i16* @g_313_0, align 1
31  %conv2 = sext i16 %0 to i64
32  store i64 %conv2, i64* @csmith_sink_, align 1
33  %1 = load i32, i32* @g_313_1, align 1
34  %conv3 = zext i32 %1 to i64
35  store i64 %conv3, i64* @csmith_sink_, align 1
36  %2 = load i32, i32* @g_313_2, align 1
37  %conv4 = sext i32 %2 to i64
38  store i64 %conv4, i64* @csmith_sink_, align 1
39  %3 = load i32, i32* @g_313_3, align 1
40  %conv5 = zext i32 %3 to i64
41  store i64 %conv5, i64* @csmith_sink_, align 1
42  %4 = load i16, i16* @g_313_4, align 1
43  %conv6 = sext i16 %4 to i64
44  store i64 %conv6, i64* @csmith_sink_, align 1
45  %5 = load i16, i16* @g_313_5, align 1
46  %conv7 = sext i16 %5 to i64
47  store i64 %conv7, i64* @csmith_sink_, align 1
48  %6 = load i16, i16* @g_313_6, align 1
49  %conv8 = sext i16 %6 to i64
50  store i64 %conv8, i64* @csmith_sink_, align 1
51  %7 = load i64, i64* getelementptr inbounds (%struct.S3, %struct.S3* @g_316, i32 0, i32 0), align 1
52  store i64 %7, i64* @csmith_sink_, align 1
53  %8 = load i16, i16* @g_316_1_0, align 1
54  %conv9 = sext i16 %8 to i64
55  store i64 %conv9, i64* @csmith_sink_, align 1
56  store i64 0, i64* @csmith_sink_, align 1
57  ret i16 0
58}
59
60