+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.
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)
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)
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)