aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2018-03-27 13:23:15 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2018-03-27 13:23:15 +0000
commitc1bbe5b3945c30510c7512869c6006285c71de34 (patch)
tree696739f0dc7f0b72728742cb02fda4683d464dda
parent18f5009ec8e87ada5228ff03f18264e93268e00f (diff)
downloadgcc-c1bbe5b3945c30510c7512869c6006285c71de34.zip
gcc-c1bbe5b3945c30510c7512869c6006285c71de34.tar.gz
gcc-c1bbe5b3945c30510c7512869c6006285c71de34.tar.bz2
re PR middle-end/84067 (gcc.dg/wmul-1.c regression on aarch64 after r257077)
2018-03-27 Richard Biener <rguenther@suse.de> PR middle-ed/84067 * match.pd ((A * C) +- (B * C) -> (A+-B) * C): Guard with explicit single_use checks. From-SVN: r258881
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/match.pd41
2 files changed, 29 insertions, 18 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 55c1f27..b670c5d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,11 @@
2018-03-27 Richard Biener <rguenther@suse.de>
+ PR middle-ed/84067
+ * match.pd ((A * C) +- (B * C) -> (A+-B) * C): Guard with
+ explicit single_use checks.
+
+2018-03-27 Richard Biener <rguenther@suse.de>
+
PR tree-optimization/85082
* tree-ssa-sccvn.c (vn_reference_lookup_or_insert_for_pieces):
Valueize the VUSE.
diff --git a/gcc/match.pd b/gcc/match.pd
index f61c4d7..3e1636c 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(). */