2018-03-01 23:13:42 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
[SimplifyLibCalls] Optimization for pow(x, n) where n is some constant
Summary:
In order to avoid calling pow function we generate repeated fmul when n is a
positive or negative whole number.
For each exponent we pre-compute Addition Chains in order to minimize the no.
of fmuls.
Refer: http://wwwhomes.uni-bielefeld.de/achim/addition_chain.html
We pre-compute addition chains for exponents upto 32 (which results in a max of
7 fmuls).
For eg:
4 = 2+2
5 = 2+3
6 = 3+3 and so on
Hence,
pow(x, 4.0) ==> y = fmul x, x
x = fmul y, y
ret x
For negative exponents, we simply compute the reciprocal of the final result.
Note: This transformation is only enabled under fast-math.
Patch by Mandeep Singh Grang <mgrang@codeaurora.org>
Reviewers: weimingz, majnemer, escha, davide, scanon, joerg
Subscribers: probinson, escha, llvm-commits
Differential Revision: http://reviews.llvm.org/D13994
llvm-svn: 254776
2015-12-05 06:00:47 +08:00
|
|
|
; RUN: opt -instcombine -S < %s | FileCheck %s
|
|
|
|
|
|
|
|
declare double @llvm.pow.f64(double, double)
|
|
|
|
declare float @llvm.pow.f32(float, float)
|
|
|
|
|
|
|
|
; pow(x, 4.0f)
|
2016-01-20 02:15:12 +08:00
|
|
|
define float @test_simplify_4f(float %x) {
|
[SimplifyLibCalls] Optimization for pow(x, n) where n is some constant
Summary:
In order to avoid calling pow function we generate repeated fmul when n is a
positive or negative whole number.
For each exponent we pre-compute Addition Chains in order to minimize the no.
of fmuls.
Refer: http://wwwhomes.uni-bielefeld.de/achim/addition_chain.html
We pre-compute addition chains for exponents upto 32 (which results in a max of
7 fmuls).
For eg:
4 = 2+2
5 = 2+3
6 = 3+3 and so on
Hence,
pow(x, 4.0) ==> y = fmul x, x
x = fmul y, y
ret x
For negative exponents, we simply compute the reciprocal of the final result.
Note: This transformation is only enabled under fast-math.
Patch by Mandeep Singh Grang <mgrang@codeaurora.org>
Reviewers: weimingz, majnemer, escha, davide, scanon, joerg
Subscribers: probinson, escha, llvm-commits
Differential Revision: http://reviews.llvm.org/D13994
llvm-svn: 254776
2015-12-05 06:00:47 +08:00
|
|
|
; CHECK-LABEL: @test_simplify_4f(
|
2018-03-01 23:13:42 +08:00
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float [[X:%.*]], [[X]]
|
|
|
|
; CHECK-NEXT: [[TMP2:%.*]] = fmul fast float [[TMP1]], [[TMP1]]
|
|
|
|
; CHECK-NEXT: ret float [[TMP2]]
|
|
|
|
;
|
2016-01-20 02:15:12 +08:00
|
|
|
%1 = call fast float @llvm.pow.f32(float %x, float 4.000000e+00)
|
[SimplifyLibCalls] Optimization for pow(x, n) where n is some constant
Summary:
In order to avoid calling pow function we generate repeated fmul when n is a
positive or negative whole number.
For each exponent we pre-compute Addition Chains in order to minimize the no.
of fmuls.
Refer: http://wwwhomes.uni-bielefeld.de/achim/addition_chain.html
We pre-compute addition chains for exponents upto 32 (which results in a max of
7 fmuls).
For eg:
4 = 2+2
5 = 2+3
6 = 3+3 and so on
Hence,
pow(x, 4.0) ==> y = fmul x, x
x = fmul y, y
ret x
For negative exponents, we simply compute the reciprocal of the final result.
Note: This transformation is only enabled under fast-math.
Patch by Mandeep Singh Grang <mgrang@codeaurora.org>
Reviewers: weimingz, majnemer, escha, davide, scanon, joerg
Subscribers: probinson, escha, llvm-commits
Differential Revision: http://reviews.llvm.org/D13994
llvm-svn: 254776
2015-12-05 06:00:47 +08:00
|
|
|
ret float %1
|
|
|
|
}
|
|
|
|
|
|
|
|
; pow(x, 3.0)
|
2016-01-20 02:15:12 +08:00
|
|
|
define double @test_simplify_3(double %x) {
|
[SimplifyLibCalls] Optimization for pow(x, n) where n is some constant
Summary:
In order to avoid calling pow function we generate repeated fmul when n is a
positive or negative whole number.
For each exponent we pre-compute Addition Chains in order to minimize the no.
of fmuls.
Refer: http://wwwhomes.uni-bielefeld.de/achim/addition_chain.html
We pre-compute addition chains for exponents upto 32 (which results in a max of
7 fmuls).
For eg:
4 = 2+2
5 = 2+3
6 = 3+3 and so on
Hence,
pow(x, 4.0) ==> y = fmul x, x
x = fmul y, y
ret x
For negative exponents, we simply compute the reciprocal of the final result.
Note: This transformation is only enabled under fast-math.
Patch by Mandeep Singh Grang <mgrang@codeaurora.org>
Reviewers: weimingz, majnemer, escha, davide, scanon, joerg
Subscribers: probinson, escha, llvm-commits
Differential Revision: http://reviews.llvm.org/D13994
llvm-svn: 254776
2015-12-05 06:00:47 +08:00
|
|
|
; CHECK-LABEL: @test_simplify_3(
|
2018-03-01 23:13:42 +08:00
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = fmul fast double [[X:%.*]], [[X]]
|
|
|
|
; CHECK-NEXT: [[TMP2:%.*]] = fmul fast double [[TMP1]], [[X]]
|
|
|
|
; CHECK-NEXT: ret double [[TMP2]]
|
|
|
|
;
|
2016-01-20 02:15:12 +08:00
|
|
|
%1 = call fast double @llvm.pow.f64(double %x, double 3.000000e+00)
|
[SimplifyLibCalls] Optimization for pow(x, n) where n is some constant
Summary:
In order to avoid calling pow function we generate repeated fmul when n is a
positive or negative whole number.
For each exponent we pre-compute Addition Chains in order to minimize the no.
of fmuls.
Refer: http://wwwhomes.uni-bielefeld.de/achim/addition_chain.html
We pre-compute addition chains for exponents upto 32 (which results in a max of
7 fmuls).
For eg:
4 = 2+2
5 = 2+3
6 = 3+3 and so on
Hence,
pow(x, 4.0) ==> y = fmul x, x
x = fmul y, y
ret x
For negative exponents, we simply compute the reciprocal of the final result.
Note: This transformation is only enabled under fast-math.
Patch by Mandeep Singh Grang <mgrang@codeaurora.org>
Reviewers: weimingz, majnemer, escha, davide, scanon, joerg
Subscribers: probinson, escha, llvm-commits
Differential Revision: http://reviews.llvm.org/D13994
llvm-svn: 254776
2015-12-05 06:00:47 +08:00
|
|
|
ret double %1
|
|
|
|
}
|
|
|
|
|
|
|
|
; pow(x, 4.0)
|
2016-01-20 02:15:12 +08:00
|
|
|
define double @test_simplify_4(double %x) {
|
[SimplifyLibCalls] Optimization for pow(x, n) where n is some constant
Summary:
In order to avoid calling pow function we generate repeated fmul when n is a
positive or negative whole number.
For each exponent we pre-compute Addition Chains in order to minimize the no.
of fmuls.
Refer: http://wwwhomes.uni-bielefeld.de/achim/addition_chain.html
We pre-compute addition chains for exponents upto 32 (which results in a max of
7 fmuls).
For eg:
4 = 2+2
5 = 2+3
6 = 3+3 and so on
Hence,
pow(x, 4.0) ==> y = fmul x, x
x = fmul y, y
ret x
For negative exponents, we simply compute the reciprocal of the final result.
Note: This transformation is only enabled under fast-math.
Patch by Mandeep Singh Grang <mgrang@codeaurora.org>
Reviewers: weimingz, majnemer, escha, davide, scanon, joerg
Subscribers: probinson, escha, llvm-commits
Differential Revision: http://reviews.llvm.org/D13994
llvm-svn: 254776
2015-12-05 06:00:47 +08:00
|
|
|
; CHECK-LABEL: @test_simplify_4(
|
2018-03-01 23:13:42 +08:00
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = fmul fast double [[X:%.*]], [[X]]
|
|
|
|
; CHECK-NEXT: [[TMP2:%.*]] = fmul fast double [[TMP1]], [[TMP1]]
|
|
|
|
; CHECK-NEXT: ret double [[TMP2]]
|
|
|
|
;
|
2016-01-20 02:15:12 +08:00
|
|
|
%1 = call fast double @llvm.pow.f64(double %x, double 4.000000e+00)
|
[SimplifyLibCalls] Optimization for pow(x, n) where n is some constant
Summary:
In order to avoid calling pow function we generate repeated fmul when n is a
positive or negative whole number.
For each exponent we pre-compute Addition Chains in order to minimize the no.
of fmuls.
Refer: http://wwwhomes.uni-bielefeld.de/achim/addition_chain.html
We pre-compute addition chains for exponents upto 32 (which results in a max of
7 fmuls).
For eg:
4 = 2+2
5 = 2+3
6 = 3+3 and so on
Hence,
pow(x, 4.0) ==> y = fmul x, x
x = fmul y, y
ret x
For negative exponents, we simply compute the reciprocal of the final result.
Note: This transformation is only enabled under fast-math.
Patch by Mandeep Singh Grang <mgrang@codeaurora.org>
Reviewers: weimingz, majnemer, escha, davide, scanon, joerg
Subscribers: probinson, escha, llvm-commits
Differential Revision: http://reviews.llvm.org/D13994
llvm-svn: 254776
2015-12-05 06:00:47 +08:00
|
|
|
ret double %1
|
|
|
|
}
|
|
|
|
|
|
|
|
; pow(x, 15.0)
|
2016-01-20 02:15:12 +08:00
|
|
|
define double @test_simplify_15(double %x) {
|
[SimplifyLibCalls] Optimization for pow(x, n) where n is some constant
Summary:
In order to avoid calling pow function we generate repeated fmul when n is a
positive or negative whole number.
For each exponent we pre-compute Addition Chains in order to minimize the no.
of fmuls.
Refer: http://wwwhomes.uni-bielefeld.de/achim/addition_chain.html
We pre-compute addition chains for exponents upto 32 (which results in a max of
7 fmuls).
For eg:
4 = 2+2
5 = 2+3
6 = 3+3 and so on
Hence,
pow(x, 4.0) ==> y = fmul x, x
x = fmul y, y
ret x
For negative exponents, we simply compute the reciprocal of the final result.
Note: This transformation is only enabled under fast-math.
Patch by Mandeep Singh Grang <mgrang@codeaurora.org>
Reviewers: weimingz, majnemer, escha, davide, scanon, joerg
Subscribers: probinson, escha, llvm-commits
Differential Revision: http://reviews.llvm.org/D13994
llvm-svn: 254776
2015-12-05 06:00:47 +08:00
|
|
|
; CHECK-LABEL: @test_simplify_15(
|
2018-03-01 23:13:42 +08:00
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = fmul fast double [[X:%.*]], [[X]]
|
|
|
|
; CHECK-NEXT: [[TMP2:%.*]] = fmul fast double [[TMP1]], [[X]]
|
|
|
|
; CHECK-NEXT: [[TMP3:%.*]] = fmul fast double [[TMP2]], [[TMP2]]
|
|
|
|
; CHECK-NEXT: [[TMP4:%.*]] = fmul fast double [[TMP3]], [[TMP3]]
|
|
|
|
; CHECK-NEXT: [[TMP5:%.*]] = fmul fast double [[TMP2]], [[TMP4]]
|
|
|
|
; CHECK-NEXT: ret double [[TMP5]]
|
|
|
|
;
|
2016-01-20 02:15:12 +08:00
|
|
|
%1 = call fast double @llvm.pow.f64(double %x, double 1.500000e+01)
|
[SimplifyLibCalls] Optimization for pow(x, n) where n is some constant
Summary:
In order to avoid calling pow function we generate repeated fmul when n is a
positive or negative whole number.
For each exponent we pre-compute Addition Chains in order to minimize the no.
of fmuls.
Refer: http://wwwhomes.uni-bielefeld.de/achim/addition_chain.html
We pre-compute addition chains for exponents upto 32 (which results in a max of
7 fmuls).
For eg:
4 = 2+2
5 = 2+3
6 = 3+3 and so on
Hence,
pow(x, 4.0) ==> y = fmul x, x
x = fmul y, y
ret x
For negative exponents, we simply compute the reciprocal of the final result.
Note: This transformation is only enabled under fast-math.
Patch by Mandeep Singh Grang <mgrang@codeaurora.org>
Reviewers: weimingz, majnemer, escha, davide, scanon, joerg
Subscribers: probinson, escha, llvm-commits
Differential Revision: http://reviews.llvm.org/D13994
llvm-svn: 254776
2015-12-05 06:00:47 +08:00
|
|
|
ret double %1
|
|
|
|
}
|
|
|
|
|
|
|
|
; pow(x, -7.0)
|
2016-01-20 02:15:12 +08:00
|
|
|
define double @test_simplify_neg_7(double %x) {
|
[SimplifyLibCalls] Optimization for pow(x, n) where n is some constant
Summary:
In order to avoid calling pow function we generate repeated fmul when n is a
positive or negative whole number.
For each exponent we pre-compute Addition Chains in order to minimize the no.
of fmuls.
Refer: http://wwwhomes.uni-bielefeld.de/achim/addition_chain.html
We pre-compute addition chains for exponents upto 32 (which results in a max of
7 fmuls).
For eg:
4 = 2+2
5 = 2+3
6 = 3+3 and so on
Hence,
pow(x, 4.0) ==> y = fmul x, x
x = fmul y, y
ret x
For negative exponents, we simply compute the reciprocal of the final result.
Note: This transformation is only enabled under fast-math.
Patch by Mandeep Singh Grang <mgrang@codeaurora.org>
Reviewers: weimingz, majnemer, escha, davide, scanon, joerg
Subscribers: probinson, escha, llvm-commits
Differential Revision: http://reviews.llvm.org/D13994
llvm-svn: 254776
2015-12-05 06:00:47 +08:00
|
|
|
; CHECK-LABEL: @test_simplify_neg_7(
|
2018-03-01 23:13:42 +08:00
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = fmul fast double [[X:%.*]], [[X]]
|
|
|
|
; CHECK-NEXT: [[TMP2:%.*]] = fmul fast double [[TMP1]], [[TMP1]]
|
|
|
|
; CHECK-NEXT: [[TMP3:%.*]] = fmul fast double [[TMP2]], [[X]]
|
|
|
|
; CHECK-NEXT: [[TMP4:%.*]] = fmul fast double [[TMP1]], [[TMP3]]
|
|
|
|
; CHECK-NEXT: [[TMP5:%.*]] = fdiv fast double 1.000000e+00, [[TMP4]]
|
|
|
|
; CHECK-NEXT: ret double [[TMP5]]
|
|
|
|
;
|
2016-01-20 02:15:12 +08:00
|
|
|
%1 = call fast double @llvm.pow.f64(double %x, double -7.000000e+00)
|
[SimplifyLibCalls] Optimization for pow(x, n) where n is some constant
Summary:
In order to avoid calling pow function we generate repeated fmul when n is a
positive or negative whole number.
For each exponent we pre-compute Addition Chains in order to minimize the no.
of fmuls.
Refer: http://wwwhomes.uni-bielefeld.de/achim/addition_chain.html
We pre-compute addition chains for exponents upto 32 (which results in a max of
7 fmuls).
For eg:
4 = 2+2
5 = 2+3
6 = 3+3 and so on
Hence,
pow(x, 4.0) ==> y = fmul x, x
x = fmul y, y
ret x
For negative exponents, we simply compute the reciprocal of the final result.
Note: This transformation is only enabled under fast-math.
Patch by Mandeep Singh Grang <mgrang@codeaurora.org>
Reviewers: weimingz, majnemer, escha, davide, scanon, joerg
Subscribers: probinson, escha, llvm-commits
Differential Revision: http://reviews.llvm.org/D13994
llvm-svn: 254776
2015-12-05 06:00:47 +08:00
|
|
|
ret double %1
|
|
|
|
}
|
|
|
|
|
|
|
|
; pow(x, -19.0)
|
2016-01-20 02:15:12 +08:00
|
|
|
define double @test_simplify_neg_19(double %x) {
|
[SimplifyLibCalls] Optimization for pow(x, n) where n is some constant
Summary:
In order to avoid calling pow function we generate repeated fmul when n is a
positive or negative whole number.
For each exponent we pre-compute Addition Chains in order to minimize the no.
of fmuls.
Refer: http://wwwhomes.uni-bielefeld.de/achim/addition_chain.html
We pre-compute addition chains for exponents upto 32 (which results in a max of
7 fmuls).
For eg:
4 = 2+2
5 = 2+3
6 = 3+3 and so on
Hence,
pow(x, 4.0) ==> y = fmul x, x
x = fmul y, y
ret x
For negative exponents, we simply compute the reciprocal of the final result.
Note: This transformation is only enabled under fast-math.
Patch by Mandeep Singh Grang <mgrang@codeaurora.org>
Reviewers: weimingz, majnemer, escha, davide, scanon, joerg
Subscribers: probinson, escha, llvm-commits
Differential Revision: http://reviews.llvm.org/D13994
llvm-svn: 254776
2015-12-05 06:00:47 +08:00
|
|
|
; CHECK-LABEL: @test_simplify_neg_19(
|
2018-03-01 23:13:42 +08:00
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = fmul fast double [[X:%.*]], [[X]]
|
|
|
|
; CHECK-NEXT: [[TMP2:%.*]] = fmul fast double [[TMP1]], [[TMP1]]
|
|
|
|
; CHECK-NEXT: [[TMP3:%.*]] = fmul fast double [[TMP2]], [[TMP2]]
|
|
|
|
; CHECK-NEXT: [[TMP4:%.*]] = fmul fast double [[TMP3]], [[TMP3]]
|
|
|
|
; CHECK-NEXT: [[TMP5:%.*]] = fmul fast double [[TMP1]], [[TMP4]]
|
|
|
|
; CHECK-NEXT: [[TMP6:%.*]] = fmul fast double [[TMP5]], [[X]]
|
|
|
|
; CHECK-NEXT: [[TMP7:%.*]] = fdiv fast double 1.000000e+00, [[TMP6]]
|
|
|
|
; CHECK-NEXT: ret double [[TMP7]]
|
|
|
|
;
|
2016-01-20 02:15:12 +08:00
|
|
|
%1 = call fast double @llvm.pow.f64(double %x, double -1.900000e+01)
|
[SimplifyLibCalls] Optimization for pow(x, n) where n is some constant
Summary:
In order to avoid calling pow function we generate repeated fmul when n is a
positive or negative whole number.
For each exponent we pre-compute Addition Chains in order to minimize the no.
of fmuls.
Refer: http://wwwhomes.uni-bielefeld.de/achim/addition_chain.html
We pre-compute addition chains for exponents upto 32 (which results in a max of
7 fmuls).
For eg:
4 = 2+2
5 = 2+3
6 = 3+3 and so on
Hence,
pow(x, 4.0) ==> y = fmul x, x
x = fmul y, y
ret x
For negative exponents, we simply compute the reciprocal of the final result.
Note: This transformation is only enabled under fast-math.
Patch by Mandeep Singh Grang <mgrang@codeaurora.org>
Reviewers: weimingz, majnemer, escha, davide, scanon, joerg
Subscribers: probinson, escha, llvm-commits
Differential Revision: http://reviews.llvm.org/D13994
llvm-svn: 254776
2015-12-05 06:00:47 +08:00
|
|
|
ret double %1
|
|
|
|
}
|
|
|
|
|
|
|
|
; pow(x, 11.23)
|
2016-01-20 02:15:12 +08:00
|
|
|
define double @test_simplify_11_23(double %x) {
|
[SimplifyLibCalls] Optimization for pow(x, n) where n is some constant
Summary:
In order to avoid calling pow function we generate repeated fmul when n is a
positive or negative whole number.
For each exponent we pre-compute Addition Chains in order to minimize the no.
of fmuls.
Refer: http://wwwhomes.uni-bielefeld.de/achim/addition_chain.html
We pre-compute addition chains for exponents upto 32 (which results in a max of
7 fmuls).
For eg:
4 = 2+2
5 = 2+3
6 = 3+3 and so on
Hence,
pow(x, 4.0) ==> y = fmul x, x
x = fmul y, y
ret x
For negative exponents, we simply compute the reciprocal of the final result.
Note: This transformation is only enabled under fast-math.
Patch by Mandeep Singh Grang <mgrang@codeaurora.org>
Reviewers: weimingz, majnemer, escha, davide, scanon, joerg
Subscribers: probinson, escha, llvm-commits
Differential Revision: http://reviews.llvm.org/D13994
llvm-svn: 254776
2015-12-05 06:00:47 +08:00
|
|
|
; CHECK-LABEL: @test_simplify_11_23(
|
2018-03-01 23:13:42 +08:00
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = call fast double @llvm.pow.f64(double [[X:%.*]], double 1.123000e+01)
|
|
|
|
; CHECK-NEXT: ret double [[TMP1]]
|
|
|
|
;
|
2016-01-20 02:15:12 +08:00
|
|
|
%1 = call fast double @llvm.pow.f64(double %x, double 1.123000e+01)
|
[SimplifyLibCalls] Optimization for pow(x, n) where n is some constant
Summary:
In order to avoid calling pow function we generate repeated fmul when n is a
positive or negative whole number.
For each exponent we pre-compute Addition Chains in order to minimize the no.
of fmuls.
Refer: http://wwwhomes.uni-bielefeld.de/achim/addition_chain.html
We pre-compute addition chains for exponents upto 32 (which results in a max of
7 fmuls).
For eg:
4 = 2+2
5 = 2+3
6 = 3+3 and so on
Hence,
pow(x, 4.0) ==> y = fmul x, x
x = fmul y, y
ret x
For negative exponents, we simply compute the reciprocal of the final result.
Note: This transformation is only enabled under fast-math.
Patch by Mandeep Singh Grang <mgrang@codeaurora.org>
Reviewers: weimingz, majnemer, escha, davide, scanon, joerg
Subscribers: probinson, escha, llvm-commits
Differential Revision: http://reviews.llvm.org/D13994
llvm-svn: 254776
2015-12-05 06:00:47 +08:00
|
|
|
ret double %1
|
|
|
|
}
|
|
|
|
|
|
|
|
; pow(x, 32.0)
|
2016-01-20 02:15:12 +08:00
|
|
|
define double @test_simplify_32(double %x) {
|
[SimplifyLibCalls] Optimization for pow(x, n) where n is some constant
Summary:
In order to avoid calling pow function we generate repeated fmul when n is a
positive or negative whole number.
For each exponent we pre-compute Addition Chains in order to minimize the no.
of fmuls.
Refer: http://wwwhomes.uni-bielefeld.de/achim/addition_chain.html
We pre-compute addition chains for exponents upto 32 (which results in a max of
7 fmuls).
For eg:
4 = 2+2
5 = 2+3
6 = 3+3 and so on
Hence,
pow(x, 4.0) ==> y = fmul x, x
x = fmul y, y
ret x
For negative exponents, we simply compute the reciprocal of the final result.
Note: This transformation is only enabled under fast-math.
Patch by Mandeep Singh Grang <mgrang@codeaurora.org>
Reviewers: weimingz, majnemer, escha, davide, scanon, joerg
Subscribers: probinson, escha, llvm-commits
Differential Revision: http://reviews.llvm.org/D13994
llvm-svn: 254776
2015-12-05 06:00:47 +08:00
|
|
|
; CHECK-LABEL: @test_simplify_32(
|
2018-03-01 23:13:42 +08:00
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = fmul fast double [[X:%.*]], [[X]]
|
|
|
|
; CHECK-NEXT: [[TMP2:%.*]] = fmul fast double [[TMP1]], [[TMP1]]
|
|
|
|
; CHECK-NEXT: [[TMP3:%.*]] = fmul fast double [[TMP2]], [[TMP2]]
|
|
|
|
; CHECK-NEXT: [[TMP4:%.*]] = fmul fast double [[TMP3]], [[TMP3]]
|
|
|
|
; CHECK-NEXT: [[TMP5:%.*]] = fmul fast double [[TMP4]], [[TMP4]]
|
|
|
|
; CHECK-NEXT: ret double [[TMP5]]
|
|
|
|
;
|
2016-01-20 02:15:12 +08:00
|
|
|
%1 = call fast double @llvm.pow.f64(double %x, double 3.200000e+01)
|
[SimplifyLibCalls] Optimization for pow(x, n) where n is some constant
Summary:
In order to avoid calling pow function we generate repeated fmul when n is a
positive or negative whole number.
For each exponent we pre-compute Addition Chains in order to minimize the no.
of fmuls.
Refer: http://wwwhomes.uni-bielefeld.de/achim/addition_chain.html
We pre-compute addition chains for exponents upto 32 (which results in a max of
7 fmuls).
For eg:
4 = 2+2
5 = 2+3
6 = 3+3 and so on
Hence,
pow(x, 4.0) ==> y = fmul x, x
x = fmul y, y
ret x
For negative exponents, we simply compute the reciprocal of the final result.
Note: This transformation is only enabled under fast-math.
Patch by Mandeep Singh Grang <mgrang@codeaurora.org>
Reviewers: weimingz, majnemer, escha, davide, scanon, joerg
Subscribers: probinson, escha, llvm-commits
Differential Revision: http://reviews.llvm.org/D13994
llvm-svn: 254776
2015-12-05 06:00:47 +08:00
|
|
|
ret double %1
|
|
|
|
}
|
|
|
|
|
|
|
|
; pow(x, 33.0)
|
2016-01-20 02:15:12 +08:00
|
|
|
define double @test_simplify_33(double %x) {
|
[SimplifyLibCalls] Optimization for pow(x, n) where n is some constant
Summary:
In order to avoid calling pow function we generate repeated fmul when n is a
positive or negative whole number.
For each exponent we pre-compute Addition Chains in order to minimize the no.
of fmuls.
Refer: http://wwwhomes.uni-bielefeld.de/achim/addition_chain.html
We pre-compute addition chains for exponents upto 32 (which results in a max of
7 fmuls).
For eg:
4 = 2+2
5 = 2+3
6 = 3+3 and so on
Hence,
pow(x, 4.0) ==> y = fmul x, x
x = fmul y, y
ret x
For negative exponents, we simply compute the reciprocal of the final result.
Note: This transformation is only enabled under fast-math.
Patch by Mandeep Singh Grang <mgrang@codeaurora.org>
Reviewers: weimingz, majnemer, escha, davide, scanon, joerg
Subscribers: probinson, escha, llvm-commits
Differential Revision: http://reviews.llvm.org/D13994
llvm-svn: 254776
2015-12-05 06:00:47 +08:00
|
|
|
; CHECK-LABEL: @test_simplify_33(
|
2018-03-01 23:13:42 +08:00
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = call fast double @llvm.pow.f64(double [[X:%.*]], double 3.300000e+01)
|
|
|
|
; CHECK-NEXT: ret double [[TMP1]]
|
|
|
|
;
|
2016-01-20 02:15:12 +08:00
|
|
|
%1 = call fast double @llvm.pow.f64(double %x, double 3.300000e+01)
|
[SimplifyLibCalls] Optimization for pow(x, n) where n is some constant
Summary:
In order to avoid calling pow function we generate repeated fmul when n is a
positive or negative whole number.
For each exponent we pre-compute Addition Chains in order to minimize the no.
of fmuls.
Refer: http://wwwhomes.uni-bielefeld.de/achim/addition_chain.html
We pre-compute addition chains for exponents upto 32 (which results in a max of
7 fmuls).
For eg:
4 = 2+2
5 = 2+3
6 = 3+3 and so on
Hence,
pow(x, 4.0) ==> y = fmul x, x
x = fmul y, y
ret x
For negative exponents, we simply compute the reciprocal of the final result.
Note: This transformation is only enabled under fast-math.
Patch by Mandeep Singh Grang <mgrang@codeaurora.org>
Reviewers: weimingz, majnemer, escha, davide, scanon, joerg
Subscribers: probinson, escha, llvm-commits
Differential Revision: http://reviews.llvm.org/D13994
llvm-svn: 254776
2015-12-05 06:00:47 +08:00
|
|
|
ret double %1
|
|
|
|
}
|
|
|
|
|