1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -instcombine < %s | FileCheck %s
4 declare double @llvm.pow.f64(double, double)
6 define double @pow_ab_a(double %a, double %b) {
7 ; CHECK-LABEL: @pow_ab_a(
8 ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.pow.f64(double [[A:%.*]], double [[B:%.*]])
9 ; CHECK-NEXT: [[MUL:%.*]] = fmul double [[TMP1]], [[A]]
10 ; CHECK-NEXT: ret double [[MUL]]
12 %1 = call double @llvm.pow.f64(double %a, double %b)
13 %mul = fmul double %1, %a
17 define double @pow_ab_a_reassoc(double %a, double %b) {
18 ; CHECK-LABEL: @pow_ab_a_reassoc(
19 ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.pow.f64(double [[A:%.*]], double [[B:%.*]])
20 ; CHECK-NEXT: [[MUL:%.*]] = fmul reassoc double [[TMP1]], [[A]]
21 ; CHECK-NEXT: ret double [[MUL]]
23 %1 = call double @llvm.pow.f64(double %a, double %b)
24 %mul = fmul reassoc double %1, %a
28 define double @pow_ab_a_reassoc_commute(double %a, double %b) {
29 ; CHECK-LABEL: @pow_ab_a_reassoc_commute(
30 ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.pow.f64(double [[A:%.*]], double [[B:%.*]])
31 ; CHECK-NEXT: [[MUL:%.*]] = fdiv reassoc double [[TMP1]], [[A]]
32 ; CHECK-NEXT: ret double [[MUL]]
34 %1 = fdiv double 1.0, %a
35 %2 = call double @llvm.pow.f64(double %a, double %b)
36 %mul = fmul reassoc double %1, %2
40 define double @pow_ab_pow_cb(double %a, double %b, double %c) {
41 ; CHECK-LABEL: @pow_ab_pow_cb(
42 ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.pow.f64(double [[A:%.*]], double [[B:%.*]])
43 ; CHECK-NEXT: [[TMP2:%.*]] = call double @llvm.pow.f64(double [[C:%.*]], double [[B]])
44 ; CHECK-NEXT: [[MUL:%.*]] = fmul double [[TMP2]], [[TMP1]]
45 ; CHECK-NEXT: ret double [[MUL]]
47 %1 = call double @llvm.pow.f64(double %a, double %b)
48 %2 = call double @llvm.pow.f64(double %c, double %b)
49 %mul = fmul double %2, %1
53 define double @pow_ab_pow_cb_reassoc(double %a, double %b, double %c) {
54 ; CHECK-LABEL: @pow_ab_pow_cb_reassoc(
55 ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.pow.f64(double [[A:%.*]], double [[B:%.*]])
56 ; CHECK-NEXT: [[TMP2:%.*]] = call double @llvm.pow.f64(double [[C:%.*]], double [[B]])
57 ; CHECK-NEXT: [[MUL:%.*]] = fmul reassoc double [[TMP2]], [[TMP1]]
58 ; CHECK-NEXT: ret double [[MUL]]
60 %1 = call double @llvm.pow.f64(double %a, double %b)
61 %2 = call double @llvm.pow.f64(double %c, double %b)
62 %mul = fmul reassoc double %2, %1
66 define double @pow_ab_pow_ac(double %a, double %b, double %c) {
67 ; CHECK-LABEL: @pow_ab_pow_ac(
68 ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.pow.f64(double [[A:%.*]], double [[B:%.*]])
69 ; CHECK-NEXT: [[TMP2:%.*]] = call double @llvm.pow.f64(double [[A]], double [[C:%.*]])
70 ; CHECK-NEXT: [[MUL:%.*]] = fmul double [[TMP2]], [[TMP1]]
71 ; CHECK-NEXT: ret double [[MUL]]
73 %1 = call double @llvm.pow.f64(double %a, double %b)
74 %2 = call double @llvm.pow.f64(double %a, double %c)
75 %mul = fmul double %2, %1
79 define double @pow_ab_x_pow_ac_reassoc(double %a, double %b, double %c) {
80 ; CHECK-LABEL: @pow_ab_x_pow_ac_reassoc(
81 ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.pow.f64(double [[A:%.*]], double [[B:%.*]])
82 ; CHECK-NEXT: [[TMP2:%.*]] = call double @llvm.pow.f64(double [[A]], double [[C:%.*]])
83 ; CHECK-NEXT: [[MUL:%.*]] = fmul reassoc double [[TMP2]], [[TMP1]]
84 ; CHECK-NEXT: ret double [[MUL]]
86 %1 = call double @llvm.pow.f64(double %a, double %b)
87 %2 = call double @llvm.pow.f64(double %a, double %c)
88 %mul = fmul reassoc double %2, %1