aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMarc Glisse <marc.glisse@inria.fr>2018-10-02 16:55:39 +0200
committerMarc Glisse <glisse@gcc.gnu.org>2018-10-02 14:55:39 +0000
commit057cf66ca3d290e0f68f66eba0e43379cb77f870 (patch)
tree52902674b39218ed120fa87d82c33c2a8886a334 /gcc
parenta1c3d798efbf20497bfb6584c9a780dc24996ee1 (diff)
downloadgcc-057cf66ca3d290e0f68f66eba0e43379cb77f870.zip
gcc-057cf66ca3d290e0f68f66eba0e43379cb77f870.tar.gz
gcc-057cf66ca3d290e0f68f66eba0e43379cb77f870.tar.bz2
No a*x+b*x factorization for signed vectors
2018-10-02 Marc Glisse <marc.glisse@inria.fr> PR middle-end/87319 * fold-const.c (fold_plusminus_mult_expr): Handle complex and vectors. * tree.c (signed_or_unsigned_type_for): Handle complex. From-SVN: r264790
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/fold-const.c2
-rw-r--r--gcc/tree.c13
3 files changed, 19 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 59a01f8..236f70c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2018-10-02 Marc Glisse <marc.glisse@inria.fr>
+
+ PR middle-end/87319
+ * fold-const.c (fold_plusminus_mult_expr): Handle complex and vectors.
+ * tree.c (signed_or_unsigned_type_for): Handle complex.
+
2018-10-02 Jeff Law <law@redhat.com>
* gimple-fold.c (get_range_strlen): Remove dead code.
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 3a6d1b1..59cedea 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -7143,7 +7143,7 @@ fold_plusminus_mult_expr (location_t loc, enum tree_code code, tree type,
if (!same)
return NULL_TREE;
- if (! INTEGRAL_TYPE_P (type)
+ if (! ANY_INTEGRAL_TYPE_P (type)
|| TYPE_OVERFLOW_WRAPS (type)
/* We are neither factoring zero nor minus one. */
|| TREE_CODE (same) == INTEGER_CST)
diff --git a/gcc/tree.c b/gcc/tree.c
index d52f877..748ece6 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -11209,7 +11209,7 @@ int_cst_value (const_tree x)
tree
signed_or_unsigned_type_for (int unsignedp, tree type)
{
- if (TREE_CODE (type) == INTEGER_TYPE && TYPE_UNSIGNED (type) == unsignedp)
+ if (ANY_INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type) == unsignedp)
return type;
if (TREE_CODE (type) == VECTOR_TYPE)
@@ -11223,6 +11223,17 @@ signed_or_unsigned_type_for (int unsignedp, tree type)
return build_vector_type (inner2, TYPE_VECTOR_SUBPARTS (type));
}
+ if (TREE_CODE (type) == COMPLEX_TYPE)
+ {
+ tree inner = TREE_TYPE (type);
+ tree inner2 = signed_or_unsigned_type_for (unsignedp, inner);
+ if (!inner2)
+ return NULL_TREE;
+ if (inner == inner2)
+ return type;
+ return build_complex_type (inner2);
+ }
+
if (!INTEGRAL_TYPE_P (type)
&& !POINTER_TYPE_P (type)
&& TREE_CODE (type) != OFFSET_TYPE)