1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -consthoist -S < %s | FileCheck %s
3 target triple = "x86_64--"
5 ; We don't want to convert constant divides because the benefit from converting
6 ; them to a mul in the backend is larget than constant materialization savings.
7 define void @signed_const_division(i64 %in1, i64 %in2, i64* %addr) {
8 ; CHECK-LABEL: @signed_const_division(
10 ; CHECK-NEXT: br label [[LOOP:%.*]]
12 ; CHECK-NEXT: [[L1:%.*]] = phi i64 [ [[RES1:%.*]], [[LOOP]] ], [ [[IN1:%.*]], [[ENTRY:%.*]] ]
13 ; CHECK-NEXT: [[L2:%.*]] = phi i64 [ [[RES2:%.*]], [[LOOP]] ], [ [[IN2:%.*]], [[ENTRY]] ]
14 ; CHECK-NEXT: [[RES1]] = sdiv i64 [[L1]], 4294967296
15 ; CHECK-NEXT: store volatile i64 [[RES1]], i64* [[ADDR:%.*]]
16 ; CHECK-NEXT: [[RES2]] = srem i64 [[L2]], 4294967296
17 ; CHECK-NEXT: store volatile i64 [[RES2]], i64* [[ADDR]]
18 ; CHECK-NEXT: [[AGAIN:%.*]] = icmp eq i64 [[RES1]], [[RES2]]
19 ; CHECK-NEXT: br i1 [[AGAIN]], label [[LOOP]], label [[END:%.*]]
21 ; CHECK-NEXT: ret void
27 %l1 = phi i64 [%res1, %loop], [%in1, %entry]
28 %l2 = phi i64 [%res2, %loop], [%in2, %entry]
29 %res1 = sdiv i64 %l1, 4294967296
30 store volatile i64 %res1, i64* %addr
31 %res2 = srem i64 %l2, 4294967296
32 store volatile i64 %res2, i64* %addr
33 %again = icmp eq i64 %res1, %res2
34 br i1 %again, label %loop, label %end
40 define void @unsigned_const_division(i64 %in1, i64 %in2, i64* %addr) {
41 ; CHECK-LABEL: @unsigned_const_division(
43 ; CHECK-NEXT: br label [[LOOP:%.*]]
45 ; CHECK-NEXT: [[L1:%.*]] = phi i64 [ [[RES1:%.*]], [[LOOP]] ], [ [[IN1:%.*]], [[ENTRY:%.*]] ]
46 ; CHECK-NEXT: [[L2:%.*]] = phi i64 [ [[RES2:%.*]], [[LOOP]] ], [ [[IN2:%.*]], [[ENTRY]] ]
47 ; CHECK-NEXT: [[RES1]] = udiv i64 [[L1]], 4294967296
48 ; CHECK-NEXT: store volatile i64 [[RES1]], i64* [[ADDR:%.*]]
49 ; CHECK-NEXT: [[RES2]] = urem i64 [[L2]], 4294967296
50 ; CHECK-NEXT: store volatile i64 [[RES2]], i64* [[ADDR]]
51 ; CHECK-NEXT: [[AGAIN:%.*]] = icmp eq i64 [[RES1]], [[RES2]]
52 ; CHECK-NEXT: br i1 [[AGAIN]], label [[LOOP]], label [[END:%.*]]
54 ; CHECK-NEXT: ret void
61 %l1 = phi i64 [%res1, %loop], [%in1, %entry]
62 %l2 = phi i64 [%res2, %loop], [%in2, %entry]
63 %res1 = udiv i64 %l1, 4294967296
64 store volatile i64 %res1, i64* %addr
65 %res2 = urem i64 %l2, 4294967296
66 store volatile i64 %res2, i64* %addr
67 %again = icmp eq i64 %res1, %res2
68 br i1 %again, label %loop, label %end
74 define i32 @PR40934() {
75 ; CHECK-LABEL: @PR40934(
76 ; CHECK-NEXT: ret i32 undef
78 ; CHECK-NEXT: [[T2:%.*]] = call i32 (i64, ...) bitcast (i32 (...)* @d to i32 (i64, ...)*)(i64 7788015061)
79 ; CHECK-NEXT: [[T3:%.*]] = and i64 [[T3]], 7788015061
80 ; CHECK-NEXT: br label [[BB:%.*]]
85 %t2 = call i32 (i64, ...) bitcast (i32 (...)* @d to i32 (i64, ...)*)(i64 7788015061)
86 %t3 = and i64 %t3, 7788015061
92 define i32 @PR40930() {
93 ; CHECK-LABEL: @PR40930(
95 ; CHECK-NEXT: [[TMP:%.*]] = alloca i32, align 4
96 ; CHECK-NEXT: br label [[BB1:%.*]]
98 ; CHECK-NEXT: br label [[BB2:%.*]]
100 ; CHECK-NEXT: br label [[BB2]]
102 ; CHECK-NEXT: [[TMP4:%.*]] = call i32 (i64, i64, ...) bitcast (i32 (...)* @c to i32 (i64, i64, ...)*)(i64 4208870971, i64 4208870971)
103 ; CHECK-NEXT: br label [[BB1]]
105 ; CHECK-NEXT: [[TMP6:%.*]] = load i32, i32* [[TMP]], align 4
106 ; CHECK-NEXT: ret i32 [[TMP6]]
109 %tmp = alloca i32, align 4
112 bb1: ; preds = %bb3, %bb
115 bb2: ; preds = %bb2, %bb1
118 bb3: ; No predecessors!
119 %tmp4 = call i32 (i64, i64, ...) bitcast (i32 (...)* @c to i32 (i64, i64, ...)*)(i64 4208870971, i64 4208870971)
122 bb5: ; No predecessors!
123 %tmp6 = load i32, i32* %tmp, align 4