1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -instcombine < %s | FileCheck %s
4 declare double @llvm.exp2.f64(double) nounwind readnone speculatable
5 declare void @use(double)
7 ; exp2(a) * exp2(b) no reassoc flags
8 define double @exp2_a_exp2_b(double %a, double %b) {
9 ; CHECK-LABEL: @exp2_a_exp2_b(
10 ; CHECK-NEXT: [[TMP:%.*]] = call double @llvm.exp2.f64(double [[A:%.*]])
11 ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.exp2.f64(double [[B:%.*]])
12 ; CHECK-NEXT: [[MUL:%.*]] = fmul double [[TMP]], [[TMP1]]
13 ; CHECK-NEXT: ret double [[MUL]]
15 %tmp = call double @llvm.exp2.f64(double %a)
16 %tmp1 = call double @llvm.exp2.f64(double %b)
17 %mul = fmul double %tmp, %tmp1
21 ; exp2(a) * exp2(b) reassoc, multiple uses
22 define double @exp2_a_exp2_b_multiple_uses(double %a, double %b) {
23 ; CHECK-LABEL: @exp2_a_exp2_b_multiple_uses(
24 ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.exp2.f64(double [[B:%.*]])
25 ; CHECK-NEXT: [[TMP:%.*]] = fadd reassoc double [[A:%.*]], [[B]]
26 ; CHECK-NEXT: [[TMP2:%.*]] = call reassoc double @llvm.exp2.f64(double [[TMP]])
27 ; CHECK-NEXT: call void @use(double [[TMP1]])
28 ; CHECK-NEXT: ret double [[TMP2]]
30 %tmp = call double @llvm.exp2.f64(double %a)
31 %tmp1 = call double @llvm.exp2.f64(double %b)
32 %mul = fmul reassoc double %tmp, %tmp1
33 call void @use(double %tmp1)
37 ; exp2(a) * exp2(b) reassoc, both with multiple uses
38 define double @exp2_a_exp2_b_multiple_uses_both(double %a, double %b) {
39 ; CHECK-LABEL: @exp2_a_exp2_b_multiple_uses_both(
40 ; CHECK-NEXT: [[TMP:%.*]] = call double @llvm.exp2.f64(double [[A:%.*]])
41 ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.exp2.f64(double [[B:%.*]])
42 ; CHECK-NEXT: [[MUL:%.*]] = fmul reassoc double [[TMP]], [[TMP1]]
43 ; CHECK-NEXT: call void @use(double [[TMP]])
44 ; CHECK-NEXT: call void @use(double [[TMP1]])
45 ; CHECK-NEXT: ret double [[MUL]]
47 %tmp = call double @llvm.exp2.f64(double %a)
48 %tmp1 = call double @llvm.exp2.f64(double %b)
49 %mul = fmul reassoc double %tmp, %tmp1
50 call void @use(double %tmp)
51 call void @use(double %tmp1)
55 ; exp2(a) * exp2(b) => exp2(a+b) with reassoc
56 define double @exp2_a_exp2_b_reassoc(double %a, double %b) {
57 ; CHECK-LABEL: @exp2_a_exp2_b_reassoc(
58 ; CHECK-NEXT: [[TMP:%.*]] = fadd reassoc double [[A:%.*]], [[B:%.*]]
59 ; CHECK-NEXT: [[TMP1:%.*]] = call reassoc double @llvm.exp2.f64(double [[TMP]])
60 ; CHECK-NEXT: ret double [[TMP1]]
62 %tmp = call double @llvm.exp2.f64(double %a)
63 %tmp1 = call double @llvm.exp2.f64(double %b)
64 %mul = fmul reassoc double %tmp, %tmp1
68 ; exp2(a) * exp2(b) * exp2(c) * exp2(d) => exp2(a+b+c+d) with reassoc
69 define double @exp2_a_exp2_b_exp2_c_exp2_d(double %a, double %b, double %c, double %d) {
70 ; CHECK-LABEL: @exp2_a_exp2_b_exp2_c_exp2_d(
71 ; CHECK-NEXT: [[TMP:%.*]] = fadd reassoc double [[A:%.*]], [[B:%.*]]
72 ; CHECK-NEXT: [[TMP1:%.*]] = fadd reassoc double [[TMP]], [[C:%.*]]
73 ; CHECK-NEXT: [[TMP2:%.*]] = fadd reassoc double [[TMP1]], [[D:%.*]]
74 ; CHECK-NEXT: [[TMP3:%.*]] = call reassoc double @llvm.exp2.f64(double [[TMP2]])
75 ; CHECK-NEXT: ret double [[TMP3]]
77 %tmp = call double @llvm.exp2.f64(double %a)
78 %tmp1 = call double @llvm.exp2.f64(double %b)
79 %mul = fmul reassoc double %tmp, %tmp1
80 %tmp2 = call double @llvm.exp2.f64(double %c)
81 %mul1 = fmul reassoc double %mul, %tmp2
82 %tmp3 = call double @llvm.exp2.f64(double %d)
83 %mul2 = fmul reassoc double %mul1, %tmp3