diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2018-02-13 22:04:09 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2018-02-13 22:04:09 +0000 |
commit | 25e15aaed275cdfef34b3ee6eb3cb4b43a48d44f (patch) | |
tree | f5e4bbb1924e4046c38bbf624a3a029efd08be5f /gcc/match.pd | |
parent | 6f574309cbd0902e9704e52c942e5947983d890a (diff) | |
parent | 80efb81dba017af2b0005f3042907b16a7ec5916 (diff) | |
download | gcc-25e15aaed275cdfef34b3ee6eb3cb4b43a48d44f.tar.gz |
Merge from trunk revision 257637.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gccgo@257643 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/match.pd')
-rw-r--r-- | gcc/match.pd | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/gcc/match.pd b/gcc/match.pd index 8631153696d..f7597110c4b 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -3992,15 +3992,36 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (logs (pows @0 @1)) (mult @1 (logs @0)))) - /* pow(C,x) -> exp(log(C)*x) if C > 0. */ + /* pow(C,x) -> exp(log(C)*x) if C > 0, + or if C is a positive power of 2, + pow(C,x) -> exp2(log2(C)*x). */ (for pows (POW) exps (EXP) logs (LOG) + exp2s (EXP2) + log2s (LOG2) (simplify (pows REAL_CST@0 @1) - (if (real_compare (GT_EXPR, TREE_REAL_CST_PTR (@0), &dconst0) - && real_isfinite (TREE_REAL_CST_PTR (@0))) - (exps (mult (logs @0) @1))))) + (if (real_compare (GT_EXPR, TREE_REAL_CST_PTR (@0), &dconst0) + && real_isfinite (TREE_REAL_CST_PTR (@0))) + (with { + const REAL_VALUE_TYPE *const value = TREE_REAL_CST_PTR (@0); + bool use_exp2 = false; + if (targetm.libc_has_function (function_c99_misc) + && value->cl == rvc_normal) + { + REAL_VALUE_TYPE frac_rvt = *value; + SET_REAL_EXP (&frac_rvt, 1); + if (real_equal (&frac_rvt, &dconst1)) + use_exp2 = true; + } + } + (if (!use_exp2) + (exps (mult (logs @0) @1)) + /* As libmvec doesn't have a vectorized exp2, defer optimizing + this until after vectorization. */ + (if (canonicalize_math_after_vectorization_p ()) + (exp2s (mult (log2s @0) @1)))))))) (for sqrts (SQRT) cbrts (CBRT) |