diff options
Diffstat (limited to 'gcc/match.pd')
-rw-r--r-- | gcc/match.pd | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/gcc/match.pd b/gcc/match.pd index f7597110c4b..b77f4ead3a8 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -1733,9 +1733,12 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) CONSTANT_CLASS_P@2) /* If one of the types wraps, use that one. */ (if (!ANY_INTEGRAL_TYPE_P (type) || TYPE_OVERFLOW_WRAPS (type)) - (if (outer_op == PLUS_EXPR) - (plus (view_convert @0) (inner_op @2 (view_convert @1))) - (minus (view_convert @0) (neg_inner_op @2 (view_convert @1)))) + /* If all 3 captures are CONSTANT_CLASS_P, punt, as we might recurse + forever if something doesn't simplify into a constant. */ + (if (!CONSTANT_CLASS_P (@0)) + (if (outer_op == PLUS_EXPR) + (plus (view_convert @0) (inner_op @2 (view_convert @1))) + (minus (view_convert @0) (neg_inner_op @2 (view_convert @1))))) (if (!ANY_INTEGRAL_TYPE_P (TREE_TYPE (@0)) || TYPE_OVERFLOW_WRAPS (TREE_TYPE (@0))) (if (outer_op == PLUS_EXPR) @@ -4003,7 +4006,14 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (simplify (pows REAL_CST@0 @1) (if (real_compare (GT_EXPR, TREE_REAL_CST_PTR (@0), &dconst0) - && real_isfinite (TREE_REAL_CST_PTR (@0))) + && real_isfinite (TREE_REAL_CST_PTR (@0)) + /* As libmvec doesn't have a vectorized exp2, defer optimizing + the use_exp2 case until after vectorization. It seems actually + beneficial for all constants to postpone this until later, + because exp(log(C)*x), while faster, will have worse precision + and if x folds into a constant too, that is unnecessary + pessimization. */ + && canonicalize_math_after_vectorization_p ()) (with { const REAL_VALUE_TYPE *const value = TREE_REAL_CST_PTR (@0); bool use_exp2 = false; @@ -4018,10 +4028,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) } (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)))))))) + (exp2s (mult (log2s @0) @1))))))) (for sqrts (SQRT) cbrts (CBRT) |