From 7318e44f9f27debf0d97a03a465dc602fcd96443 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 26 Jun 2015 07:50:12 +0000 Subject: [PATCH] match.pd: Allow associating FLOAT_TYPE_P when flag_associative_math. 2015-06-26 Richard Biener * match.pd: Allow associating FLOAT_TYPE_P when flag_associative_math. * gfortran.dg/reassoc_3.f90: Adjust. 2015-06-26 Richard Biener * match.pd: Allow (p +p off1) +p off2 to (p +p (off1 + off2)) irrespective on whether the inner operation has a single use of both off are constant. From-SVN: r224995 --- gcc/ChangeLog | 10 ++++++++++ gcc/match.pd | 10 ++++++---- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gfortran.dg/reassoc_3.f90 | 3 +-- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 92cacd457e5..21627b470db 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2015-06-26 Richard Biener + + * match.pd: Allow associating FLOAT_TYPE_P when flag_associative_math. + +2015-06-26 Richard Biener + + * match.pd: Allow (p +p off1) +p off2 to (p +p (off1 + off2)) + irrespective on whether the inner operation has a single use + of both off are constant. + 2015-06-26 Uros Bizjak Segher Boessenkool diff --git a/gcc/match.pd b/gcc/match.pd index 292ce6d75c6..b1a88272618 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -503,7 +503,8 @@ along with GCC; see the file COPYING3. If not see /* Associate (p +p off1) +p off2 as (p +p (off1 + off2)). */ (simplify (pointer_plus (pointer_plus@2 @0 @1) @3) - (if (single_use (@2)) + (if (single_use (@2) + || (TREE_CODE (@1) == INTEGER_CST && TREE_CODE (@3) == INTEGER_CST)) (pointer_plus @0 (plus @1 @3)))) /* Pattern match @@ -561,9 +562,10 @@ along with GCC; see the file COPYING3. If not see && !TYPE_OVERFLOW_SANITIZED (type)) (convert @1))) - /* We can't reassociate floating-point or fixed-point plus or minus - because of saturation to +-Inf. */ - (if (!FLOAT_TYPE_P (type) && !FIXED_POINT_TYPE_P (type)) + /* We can't reassociate floating-point unless -fassociative-math + or fixed-point plus or minus because of saturation to +-Inf. */ + (if ((!FLOAT_TYPE_P (type) || flag_associative_math) + && !FIXED_POINT_TYPE_P (type)) /* Match patterns that allow contracting a plus-minus pair irrespective of overflow issues. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 74462f9539b..bccda4a31df 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2015-06-26 Richard Biener + + * gfortran.dg/reassoc_3.f90: Adjust. + 2015-06-26 Uros Bizjak PR target/66412 diff --git a/gcc/testsuite/gfortran.dg/reassoc_3.f90 b/gcc/testsuite/gfortran.dg/reassoc_3.f90 index 7331b0cd8e0..ac2f6aacf08 100644 --- a/gcc/testsuite/gfortran.dg/reassoc_3.f90 +++ b/gcc/testsuite/gfortran.dg/reassoc_3.f90 @@ -14,5 +14,4 @@ function test(a) end ! { dg-final { scan-tree-dump "b = 5" "original" } } -! { dg-final { scan-tree-dump "c_. = .a" "optimized" } } -! { dg-final { scan-tree-dump "return c_.;" "optimized" } } +! { dg-final { scan-tree-dump-times " = " 1 "optimized" } } -- 2.30.2