aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMarc Glisse <marc.glisse@inria.fr>2019-06-11 14:48:26 +0200
committerMarc Glisse <glisse@gcc.gnu.org>2019-06-11 12:48:26 +0000
commit7ac9a201848f020a7803c5b3e20dc4768a992c40 (patch)
tree27d7bb195ce6f6a3b993797ddb942ffb1d895886 /gcc
parent92812757648109dc6cd35a52374ab3f6e9f44f78 (diff)
downloadgcc-7ac9a201848f020a7803c5b3e20dc4768a992c40.zip
gcc-7ac9a201848f020a7803c5b3e20dc4768a992c40.tar.gz
gcc-7ac9a201848f020a7803c5b3e20dc4768a992c40.tar.bz2
fold_real_zero_addition_p for vectors
2019-06-11 Marc Glisse <marc.glisse@inria.fr> PR tree-optimization/62041 * fold-const.c (fold_real_zero_addition_p): Handle vectors. From-SVN: r272151
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/fold-const.c17
2 files changed, 16 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f115982..211a55d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2019-06-11 Marc Glisse <marc.glisse@inria.fr>
+
+ PR tree-optimization/62041
+ * fold-const.c (fold_real_zero_addition_p): Handle vectors.
+
2019-06-11 Jason Merrill <jason@redhat.com>
* gdbhooks.py (TreePrinter.to_string): Recognize ggc_free'd memory.
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 8252cc6..0ca472d 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -6722,15 +6722,21 @@ fold_real_zero_addition_p (const_tree type, const_tree addend, int negate)
return false;
/* Don't allow the fold with -fsignaling-nans. */
- if (HONOR_SNANS (element_mode (type)))
+ if (HONOR_SNANS (type))
return false;
/* Allow the fold if zeros aren't signed, or their sign isn't important. */
- if (!HONOR_SIGNED_ZEROS (element_mode (type)))
+ if (!HONOR_SIGNED_ZEROS (type))
return true;
+ /* There is no case that is safe for all rounding modes. */
+ if (HONOR_SIGN_DEPENDENT_ROUNDING (type))
+ return false;
+
/* In a vector or complex, we would need to check the sign of all zeros. */
- if (TREE_CODE (addend) != REAL_CST)
+ if (TREE_CODE (addend) == VECTOR_CST)
+ addend = uniform_vector_p (addend);
+ if (!addend || TREE_CODE (addend) != REAL_CST)
return false;
/* Treat x + -0 as x - 0 and x - -0 as x + 0. */
@@ -6739,9 +6745,8 @@ fold_real_zero_addition_p (const_tree type, const_tree addend, int negate)
/* The mode has signed zeros, and we have to honor their sign.
In this situation, there is only one case we can return true for.
- X - 0 is the same as X unless rounding towards -infinity is
- supported. */
- return negate && !HONOR_SIGN_DEPENDENT_ROUNDING (element_mode (type));
+ X - 0 is the same as X with default rounding. */
+ return negate;
}
/* Subroutine of match.pd that optimizes comparisons of a division by