blob: 34c982010ecfe5933136800b12083cfcdde00699 [file] [log] [blame]
Alexey Bataev84ad9ae2017-08-17 17:26:52 +00001; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -simplifycfg -S < %s | FileCheck %s
3
4%struct.Counters = type { i64, i64, i64, [8 x i8] }
5
6@m = global i64 3, align 8
7@counters = global %struct.Counters zeroinitializer, align 16
8
9define i32 @main() local_unnamed_addr {
10; CHECK-LABEL: @main(
11; CHECK-NEXT: entry:
12; CHECK-NEXT: [[TMP0:%.*]] = load <2 x i64>, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8
13; CHECK-NEXT: [[TMP1:%.*]] = add nsw <2 x i64> [[TMP0]], <i64 1, i64 1>
14; CHECK-NEXT: store <2 x i64> [[TMP1]], <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8
15; CHECK-NEXT: [[TMP2:%.*]] = load i64, i64* @m, align 8
16; CHECK-NEXT: [[AND:%.*]] = and i64 [[TMP2]], 1
17; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i64 [[AND]], 0
18; CHECK-NEXT: [[TMP3:%.*]] = add nsw <2 x i64> [[TMP0]], <i64 2, i64 2>
19; CHECK-NEXT: [[TMP4:%.*]] = select i1 [[TOBOOL]], <2 x i64> [[TMP1]], <2 x i64> [[TMP3]]
20; CHECK-NEXT: [[AND4:%.*]] = and i64 [[TMP2]], 2
21; CHECK-NEXT: [[TOBOOL5:%.*]] = icmp eq i64 [[AND4]], 0
22; CHECK-NEXT: [[TMP5:%.*]] = add nsw <2 x i64> [[TMP4]], <i64 1, i64 1>
23; CHECK-NEXT: [[DOT:%.*]] = select i1 [[TOBOOL5]], <2 x i64> [[TMP4]], <2 x i64> [[TMP5]]
24; CHECK-NEXT: [[TMP6:%.*]] = xor i1 [[TOBOOL]], true
25; CHECK-NEXT: [[TMP7:%.*]] = xor i1 [[TOBOOL5]], true
26; CHECK-NEXT: [[TMP8:%.*]] = or i1 [[TMP6]], [[TMP7]]
27; CHECK-NEXT: br i1 [[TMP8]], label [[TMP9:%.*]], label [[TMP10:%.*]]
28; CHECK: store <2 x i64> [[DOT]], <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*)
29; CHECK-NEXT: br label [[TMP10]]
30; CHECK: ret i32 0
31;
32entry:
33 %0 = load <2 x i64>, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8
34 %1 = add nsw <2 x i64> %0, <i64 1, i64 1>
35 store <2 x i64> %1, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8
36 %2 = load i64, i64* @m, align 8
37 %and = and i64 %2, 1
38 %tobool = icmp eq i64 %and, 0
39 br i1 %tobool, label %if.end, label %if.then
40
41if.then: ; preds = %entry
42 %3 = add nsw <2 x i64> %0, <i64 2, i64 2>
43 store <2 x i64> %3, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8
44 br label %if.end
45
46if.end: ; preds = %entry, %if.then
47 %4 = phi <2 x i64> [ %1, %entry ], [ %3, %if.then ]
48 %and4 = and i64 %2, 2
49 %tobool5 = icmp eq i64 %and4, 0
50 br i1 %tobool5, label %if.end9, label %if.then6
51
52if.then6: ; preds = %if.end
53 %5 = add nsw <2 x i64> %4, <i64 1, i64 1>
54 store <2 x i64> %5, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8
55 br label %if.end9
56
57if.end9: ; preds = %if.end, %if.then6
58 ret i32 0
59}