From: Richard Biener Date: Tue, 27 Mar 2018 13:23:15 +0000 (+0000) Subject: re PR middle-end/84067 (gcc.dg/wmul-1.c regression on aarch64 after r257077) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c1bbe5b3945c30510c7512869c6006285c71de34;p=gcc.git re PR middle-end/84067 (gcc.dg/wmul-1.c regression on aarch64 after r257077) 2018-03-27 Richard Biener PR middle-ed/84067 * match.pd ((A * C) +- (B * C) -> (A+-B) * C): Guard with explicit single_use checks. From-SVN: r258881 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 55c1f279d68..b670c5da8be 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-03-27 Richard Biener + + PR middle-ed/84067 + * match.pd ((A * C) +- (B * C) -> (A+-B) * C): Guard with + explicit single_use checks. + 2018-03-27 Richard Biener PR tree-optimization/85082 diff --git a/gcc/match.pd b/gcc/match.pd index f61c4d7440a..3e1636c41a4 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -1948,30 +1948,35 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) && (!FLOAT_TYPE_P (type) || flag_associative_math)) (for plusminus (plus minus) (simplify - (plusminus (mult:cs @0 @1) (mult:cs @0 @2)) - (if (!ANY_INTEGRAL_TYPE_P (type) - || TYPE_OVERFLOW_WRAPS (type) - || (INTEGRAL_TYPE_P (type) - && tree_expr_nonzero_p (@0) - && expr_not_equal_to (@0, wi::minus_one (TYPE_PRECISION (type))))) - (mult (plusminus @1 @2) @0))) - /* We cannot generate constant 1 for fract. */ - (if (!ALL_FRACT_MODE_P (TYPE_MODE (type))) - (simplify - (plusminus @0 (mult:cs @0 @2)) - (if (!ANY_INTEGRAL_TYPE_P (type) + (plusminus (mult:cs@3 @0 @1) (mult:cs@4 @0 @2)) + (if ((!ANY_INTEGRAL_TYPE_P (type) || TYPE_OVERFLOW_WRAPS (type) || (INTEGRAL_TYPE_P (type) && tree_expr_nonzero_p (@0) && expr_not_equal_to (@0, wi::minus_one (TYPE_PRECISION (type))))) + /* If @1 +- @2 is constant require a hard single-use on either + original operand (but not on both). */ + && (single_use (@3) || single_use (@4))) + (mult (plusminus @1 @2) @0))) + /* We cannot generate constant 1 for fract. */ + (if (!ALL_FRACT_MODE_P (TYPE_MODE (type))) + (simplify + (plusminus @0 (mult:c@3 @0 @2)) + (if ((!ANY_INTEGRAL_TYPE_P (type) + || TYPE_OVERFLOW_WRAPS (type) + || (INTEGRAL_TYPE_P (type) + && tree_expr_nonzero_p (@0) + && expr_not_equal_to (@0, wi::minus_one (TYPE_PRECISION (type))))) + && single_use (@3)) (mult (plusminus { build_one_cst (type); } @2) @0))) (simplify - (plusminus (mult:cs @0 @2) @0) - (if (!ANY_INTEGRAL_TYPE_P (type) - || TYPE_OVERFLOW_WRAPS (type) - || (INTEGRAL_TYPE_P (type) - && tree_expr_nonzero_p (@0) - && expr_not_equal_to (@0, wi::minus_one (TYPE_PRECISION (type))))) + (plusminus (mult:c@3 @0 @2) @0) + (if ((!ANY_INTEGRAL_TYPE_P (type) + || TYPE_OVERFLOW_WRAPS (type) + || (INTEGRAL_TYPE_P (type) + && tree_expr_nonzero_p (@0) + && expr_not_equal_to (@0, wi::minus_one (TYPE_PRECISION (type))))) + && single_use (@3)) (mult (plusminus @2 { build_one_cst (type); }) @0)))))) /* Simplifications of MIN_EXPR, MAX_EXPR, fmin() and fmax(). */