aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2017-08-30 11:19:29 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2017-08-30 11:19:29 +0000
commitb397965cae46d88d4c274fb2ecdde9a4714a4e6a (patch)
treedc2102813ae17dff7c73a78ce34cfb4b7c869d3f /gcc
parentd21cefc26f716395b03e3c0d379ecac04656f963 (diff)
downloadgcc-b397965cae46d88d4c274fb2ecdde9a4714a4e6a.zip
gcc-b397965cae46d88d4c274fb2ecdde9a4714a4e6a.tar.gz
gcc-b397965cae46d88d4c274fb2ecdde9a4714a4e6a.tar.bz2
[65/77] Add a SCALAR_TYPE_MODE macro
This patch adds a SCALAR_TYPE_MODE macro, along the same lines as SCALAR_INT_TYPE_MODE and SCALAR_FLOAT_TYPE_MODE. It also adds two instances of as_a <scalar_mode> to c_common_type, when converting an unsigned fixed-point SCALAR_TYPE_MODE to the equivalent signed mode. 2017-08-30 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * tree.h (SCALAR_TYPE_MODE): New macro. * expr.c (expand_expr_addr_expr_1): Use it. (expand_expr_real_2): Likewise. * fold-const.c (fold_convert_const_fixed_from_fixed): Likeise. (fold_convert_const_fixed_from_int): Likewise. (fold_convert_const_fixed_from_real): Likewise. (native_encode_fixed): Likewise (native_encode_complex): Likewise (native_encode_vector): Likewise. (native_interpret_fixed): Likewise. (native_interpret_real): Likewise. (native_interpret_complex): Likewise. (native_interpret_vector): Likewise. * omp-simd-clone.c (simd_clone_adjust_return_type): Likewise. (simd_clone_adjust_argument_types): Likewise. (simd_clone_init_simd_arrays): Likewise. (simd_clone_adjust): Likewise. * stor-layout.c (layout_type): Likewise. * tree.c (build_minus_one_cst): Likewise. * tree-cfg.c (verify_gimple_assign_ternary): Likewise. * tree-inline.c (estimate_move_cost): Likewise. * tree-ssa-math-opts.c (convert_plusminus_to_widen): Likewise. * tree-vect-loop.c (vect_create_epilog_for_reduction): Likewise. (vectorizable_reduction): Likewise. * tree-vect-patterns.c (vect_recog_widen_mult_pattern): Likewise. (vect_recog_mixed_size_cond_pattern): Likewise. (check_bool_pattern): Likewise. (adjust_bool_pattern): Likewise. (search_type_for_mask_1): Likewise. * tree-vect-slp.c (vect_schedule_slp_instance): Likewise. * tree-vect-stmts.c (vectorizable_conversion): Likewise. (vectorizable_load): Likewise. (vectorizable_store): Likewise. * ubsan.c (ubsan_encode_value): Likewise. * varasm.c (output_constant): Likewise. gcc/c-family/ * c-lex.c (interpret_fixed): Use SCALAR_TYPE_MODE. * c-common.c (c_build_vec_perm_expr): Likewise. gcc/c/ * c-typeck.c (build_binary_op): Use SCALAR_TYPE_MODE. (c_common_type): Likewise. Use as_a <scalar_mode> when setting m1 and m2 to the signed equivalent of a fixed-point SCALAR_TYPE_MODE. gcc/cp/ * typeck.c (cp_build_binary_op): Use SCALAR_TYPE_MODE. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r251516
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog40
-rw-r--r--gcc/c-family/ChangeLog7
-rw-r--r--gcc/c-family/c-common.c4
-rw-r--r--gcc/c-family/c-lex.c2
-rw-r--r--gcc/c/ChangeLog9
-rw-r--r--gcc/c/c-typeck.c18
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/typeck.c4
-rw-r--r--gcc/expr.c4
-rw-r--r--gcc/fold-const.c24
-rw-r--r--gcc/omp-simd-clone.c12
-rw-r--r--gcc/stor-layout.c14
-rw-r--r--gcc/tree-cfg.c2
-rw-r--r--gcc/tree-inline.c2
-rw-r--r--gcc/tree-ssa-math-opts.c7
-rw-r--r--gcc/tree-vect-loop.c6
-rw-r--r--gcc/tree-vect-patterns.c16
-rw-r--r--gcc/tree-vect-slp.c2
-rw-r--r--gcc/tree-vect-stmts.c19
-rw-r--r--gcc/tree.c5
-rw-r--r--gcc/tree.h2
-rw-r--r--gcc/ubsan.c9
-rw-r--r--gcc/varasm.c2
23 files changed, 145 insertions, 71 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d9895f3..f67f411 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -2,6 +2,46 @@
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
+ * tree.h (SCALAR_TYPE_MODE): New macro.
+ * expr.c (expand_expr_addr_expr_1): Use it.
+ (expand_expr_real_2): Likewise.
+ * fold-const.c (fold_convert_const_fixed_from_fixed): Likeise.
+ (fold_convert_const_fixed_from_int): Likewise.
+ (fold_convert_const_fixed_from_real): Likewise.
+ (native_encode_fixed): Likewise
+ (native_encode_complex): Likewise
+ (native_encode_vector): Likewise.
+ (native_interpret_fixed): Likewise.
+ (native_interpret_real): Likewise.
+ (native_interpret_complex): Likewise.
+ (native_interpret_vector): Likewise.
+ * omp-simd-clone.c (simd_clone_adjust_return_type): Likewise.
+ (simd_clone_adjust_argument_types): Likewise.
+ (simd_clone_init_simd_arrays): Likewise.
+ (simd_clone_adjust): Likewise.
+ * stor-layout.c (layout_type): Likewise.
+ * tree.c (build_minus_one_cst): Likewise.
+ * tree-cfg.c (verify_gimple_assign_ternary): Likewise.
+ * tree-inline.c (estimate_move_cost): Likewise.
+ * tree-ssa-math-opts.c (convert_plusminus_to_widen): Likewise.
+ * tree-vect-loop.c (vect_create_epilog_for_reduction): Likewise.
+ (vectorizable_reduction): Likewise.
+ * tree-vect-patterns.c (vect_recog_widen_mult_pattern): Likewise.
+ (vect_recog_mixed_size_cond_pattern): Likewise.
+ (check_bool_pattern): Likewise.
+ (adjust_bool_pattern): Likewise.
+ (search_type_for_mask_1): Likewise.
+ * tree-vect-slp.c (vect_schedule_slp_instance): Likewise.
+ * tree-vect-stmts.c (vectorizable_conversion): Likewise.
+ (vectorizable_load): Likewise.
+ (vectorizable_store): Likewise.
+ * ubsan.c (ubsan_encode_value): Likewise.
+ * varasm.c (output_constant): Likewise.
+
+2017-08-30 Richard Sandiford <richard.sandiford@linaro.org>
+ Alan Hayward <alan.hayward@arm.com>
+ David Sherwood <david.sherwood@arm.com>
+
* coretypes.h (scalar_mode): New class.
* machmode.h (scalar_mode): Likewise.
(scalar_mode::includes_p): New function.
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index fe3fd58..a715b57 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -2,6 +2,13 @@
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
+ * c-lex.c (interpret_fixed): Use SCALAR_TYPE_MODE.
+ * c-common.c (c_build_vec_perm_expr): Likewise.
+
+2017-08-30 Richard Sandiford <richard.sandiford@linaro.org>
+ Alan Hayward <alan.hayward@arm.com>
+ David Sherwood <david.sherwood@arm.com>
+
* c-attribs.c (handle_mode_attribute): Check for a scalar_int_mode
before calling targetm.addr_space.valid_pointer_mode.
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 9754a66..18b2d1a 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -1031,8 +1031,8 @@ c_build_vec_perm_expr (location_t loc, tree v0, tree v1, tree mask,
return error_mark_node;
}
- if (GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (TREE_TYPE (v0))))
- != GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (TREE_TYPE (mask)))))
+ if (GET_MODE_BITSIZE (SCALAR_TYPE_MODE (TREE_TYPE (TREE_TYPE (v0))))
+ != GET_MODE_BITSIZE (SCALAR_TYPE_MODE (TREE_TYPE (TREE_TYPE (mask)))))
{
if (complain)
error_at (loc, "__builtin_shuffle argument vector(s) inner type "
diff --git a/gcc/c-family/c-lex.c b/gcc/c-family/c-lex.c
index a614b26..8342800 100644
--- a/gcc/c-family/c-lex.c
+++ b/gcc/c-family/c-lex.c
@@ -1110,7 +1110,7 @@ interpret_fixed (const cpp_token *token, unsigned int flags)
memcpy (copy, token->val.str.text, copylen);
copy[copylen] = '\0';
- fixed_from_string (&fixed, copy, TYPE_MODE (type));
+ fixed_from_string (&fixed, copy, SCALAR_TYPE_MODE (type));
/* Create a node with determined type and value. */
value = build_fixed (type, fixed);
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 0cf7bd2..dc269d5 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,12 @@
+2017-08-30 Richard Sandiford <richard.sandiford@linaro.org>
+ Alan Hayward <alan.hayward@arm.com>
+ David Sherwood <david.sherwood@arm.com>
+
+ * c-typeck.c (build_binary_op): Use SCALAR_TYPE_MODE.
+ (c_common_type): Likewise. Use as_a <scalar_mode> when setting
+ m1 and m2 to the signed equivalent of a fixed-point
+ SCALAR_TYPE_MODE.
+
2017-08-24 David Malcolm <dmalcolm@redhat.com>
* c-tree.h (c_expr::get_location) Use EXPR_HAS_LOCATION rather
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index d7ca148..135dd9d 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -812,11 +812,11 @@ c_common_type (tree t1, tree t2)
if (code1 == FIXED_POINT_TYPE || code2 == FIXED_POINT_TYPE)
{
unsigned int unsignedp = 0, satp = 0;
- machine_mode m1, m2;
+ scalar_mode m1, m2;
unsigned int fbit1, ibit1, fbit2, ibit2, max_fbit, max_ibit;
- m1 = TYPE_MODE (t1);
- m2 = TYPE_MODE (t2);
+ m1 = SCALAR_TYPE_MODE (t1);
+ m2 = SCALAR_TYPE_MODE (t2);
/* If one input type is saturating, the result type is saturating. */
if (TYPE_SATURATING (t1) || TYPE_SATURATING (t2))
@@ -848,7 +848,8 @@ c_common_type (tree t1, tree t2)
mclass = MODE_ACCUM;
else
gcc_unreachable ();
- m1 = mode_for_size (GET_MODE_PRECISION (m1), mclass, 0);
+ m1 = as_a <scalar_mode>
+ (mode_for_size (GET_MODE_PRECISION (m1), mclass, 0));
}
if (code2 == FIXED_POINT_TYPE && TYPE_UNSIGNED (t2))
{
@@ -859,7 +860,8 @@ c_common_type (tree t1, tree t2)
mclass = MODE_ACCUM;
else
gcc_unreachable ();
- m2 = mode_for_size (GET_MODE_PRECISION (m2), mclass, 0);
+ m2 = as_a <scalar_mode>
+ (mode_for_size (GET_MODE_PRECISION (m2), mclass, 0));
}
}
@@ -11414,7 +11416,8 @@ build_binary_op (location_t location, enum tree_code code,
/* Always construct signed integer vector type. */
intt = c_common_type_for_size (GET_MODE_BITSIZE
- (TYPE_MODE (TREE_TYPE (type0))), 0);
+ (SCALAR_TYPE_MODE
+ (TREE_TYPE (type0))), 0);
result_type = build_opaque_vector_type (intt,
TYPE_VECTOR_SUBPARTS (type0));
converted = 1;
@@ -11573,7 +11576,8 @@ build_binary_op (location_t location, enum tree_code code,
/* Always construct signed integer vector type. */
intt = c_common_type_for_size (GET_MODE_BITSIZE
- (TYPE_MODE (TREE_TYPE (type0))), 0);
+ (SCALAR_TYPE_MODE
+ (TREE_TYPE (type0))), 0);
result_type = build_opaque_vector_type (intt,
TYPE_VECTOR_SUBPARTS (type0));
converted = 1;
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 42375e9..69267c0 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -2,6 +2,12 @@
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
+ * typeck.c (cp_build_binary_op): Use SCALAR_TYPE_MODE.
+
+2017-08-30 Richard Sandiford <richard.sandiford@linaro.org>
+ Alan Hayward <alan.hayward@arm.com>
+ David Sherwood <david.sherwood@arm.com>
+
* cvt.c (cp_convert_to_pointer): Use SCALAR_INT_TYPE_MODE.
2017-08-30 Richard Sandiford <richard.sandiford@linaro.org>
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 63667f3..171c2df 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -4952,8 +4952,8 @@ cp_build_binary_op (location_t location,
}
/* Always construct signed integer vector type. */
- intt = c_common_type_for_size (GET_MODE_BITSIZE
- (TYPE_MODE (TREE_TYPE (type0))), 0);
+ intt = c_common_type_for_size
+ (GET_MODE_BITSIZE (SCALAR_TYPE_MODE (TREE_TYPE (type0))), 0);
if (!intt)
{
if (complain & tf_error)
diff --git a/gcc/expr.c b/gcc/expr.c
index 71a81ef..c586e7c 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -7766,7 +7766,7 @@ expand_expr_addr_expr_1 (tree exp, rtx target, scalar_int_mode tmode,
The expression is therefore always offset by the size of the
scalar type. */
offset = 0;
- bitpos = GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (exp)));
+ bitpos = GET_MODE_BITSIZE (SCALAR_TYPE_MODE (TREE_TYPE (exp)));
inner = TREE_OPERAND (exp, 0);
break;
@@ -9443,7 +9443,7 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode,
{
tree sel_type = TREE_TYPE (treeop2);
machine_mode vmode
- = mode_for_vector (TYPE_MODE (TREE_TYPE (sel_type)),
+ = mode_for_vector (SCALAR_TYPE_MODE (TREE_TYPE (sel_type)),
TYPE_VECTOR_SUBPARTS (sel_type));
gcc_assert (GET_MODE_CLASS (vmode) == MODE_VECTOR_INT);
op2 = simplify_subreg (vmode, op2, TYPE_MODE (sel_type), 0);
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index e61195d..c921f1c 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -2050,8 +2050,8 @@ fold_convert_const_fixed_from_fixed (tree type, const_tree arg1)
tree t;
bool overflow_p;
- overflow_p = fixed_convert (&value, TYPE_MODE (type), &TREE_FIXED_CST (arg1),
- TYPE_SATURATING (type));
+ overflow_p = fixed_convert (&value, SCALAR_TYPE_MODE (type),
+ &TREE_FIXED_CST (arg1), TYPE_SATURATING (type));
t = build_fixed (type, value);
/* Propagate overflow flags. */
@@ -2079,7 +2079,7 @@ fold_convert_const_fixed_from_int (tree type, const_tree arg1)
else
di.high = TREE_INT_CST_ELT (arg1, 1);
- overflow_p = fixed_convert_from_int (&value, TYPE_MODE (type), di,
+ overflow_p = fixed_convert_from_int (&value, SCALAR_TYPE_MODE (type), di,
TYPE_UNSIGNED (TREE_TYPE (arg1)),
TYPE_SATURATING (type));
t = build_fixed (type, value);
@@ -2100,7 +2100,7 @@ fold_convert_const_fixed_from_real (tree type, const_tree arg1)
tree t;
bool overflow_p;
- overflow_p = fixed_convert_from_real (&value, TYPE_MODE (type),
+ overflow_p = fixed_convert_from_real (&value, SCALAR_TYPE_MODE (type),
&TREE_REAL_CST (arg1),
TYPE_SATURATING (type));
t = build_fixed (type, value);
@@ -7027,7 +7027,7 @@ static int
native_encode_fixed (const_tree expr, unsigned char *ptr, int len, int off)
{
tree type = TREE_TYPE (expr);
- machine_mode mode = TYPE_MODE (type);
+ scalar_mode mode = SCALAR_TYPE_MODE (type);
int total_bytes = GET_MODE_SIZE (mode);
FIXED_VALUE_TYPE value;
tree i_value, i_type;
@@ -7129,7 +7129,7 @@ native_encode_complex (const_tree expr, unsigned char *ptr, int len, int off)
return 0;
part = TREE_IMAGPART (expr);
if (off != -1)
- off = MAX (0, off - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (part))));
+ off = MAX (0, off - GET_MODE_SIZE (SCALAR_TYPE_MODE (TREE_TYPE (part))));
isize = native_encode_expr (part, ptr+rsize, len-rsize, off);
if (off == -1
&& isize != rsize)
@@ -7153,7 +7153,7 @@ native_encode_vector (const_tree expr, unsigned char *ptr, int len, int off)
offset = 0;
count = VECTOR_CST_NELTS (expr);
itype = TREE_TYPE (TREE_TYPE (expr));
- size = GET_MODE_SIZE (TYPE_MODE (itype));
+ size = GET_MODE_SIZE (SCALAR_TYPE_MODE (itype));
for (i = 0; i < count; i++)
{
if (off >= size)
@@ -7281,7 +7281,8 @@ native_interpret_int (tree type, const unsigned char *ptr, int len)
static tree
native_interpret_fixed (tree type, const unsigned char *ptr, int len)
{
- int total_bytes = GET_MODE_SIZE (TYPE_MODE (type));
+ scalar_mode mode = SCALAR_TYPE_MODE (type);
+ int total_bytes = GET_MODE_SIZE (mode);
double_int result;
FIXED_VALUE_TYPE fixed_value;
@@ -7290,7 +7291,7 @@ native_interpret_fixed (tree type, const unsigned char *ptr, int len)
return NULL_TREE;
result = double_int::from_buffer (ptr, total_bytes);
- fixed_value = fixed_from_double_int (result, TYPE_MODE (type));
+ fixed_value = fixed_from_double_int (result, mode);
return build_fixed (type, fixed_value);
}
@@ -7312,7 +7313,6 @@ native_interpret_real (tree type, const unsigned char *ptr, int len)
REAL_VALUE_TYPE r;
long tmp[6];
- total_bytes = GET_MODE_SIZE (TYPE_MODE (type));
if (total_bytes > len || total_bytes > 24)
return NULL_TREE;
int words = (32 / BITS_PER_UNIT) / UNITS_PER_WORD;
@@ -7367,7 +7367,7 @@ native_interpret_complex (tree type, const unsigned char *ptr, int len)
int size;
etype = TREE_TYPE (type);
- size = GET_MODE_SIZE (TYPE_MODE (etype));
+ size = GET_MODE_SIZE (SCALAR_TYPE_MODE (etype));
if (size * 2 > len)
return NULL_TREE;
rpart = native_interpret_expr (etype, ptr, size);
@@ -7392,7 +7392,7 @@ native_interpret_vector (tree type, const unsigned char *ptr, int len)
tree *elements;
etype = TREE_TYPE (type);
- size = GET_MODE_SIZE (TYPE_MODE (etype));
+ size = GET_MODE_SIZE (SCALAR_TYPE_MODE (etype));
count = TYPE_VECTOR_SUBPARTS (type);
if (size * count > len)
return NULL_TREE;
diff --git a/gcc/omp-simd-clone.c b/gcc/omp-simd-clone.c
index 0a3a386..18eecd4 100644
--- a/gcc/omp-simd-clone.c
+++ b/gcc/omp-simd-clone.c
@@ -496,7 +496,7 @@ simd_clone_adjust_return_type (struct cgraph_node *node)
veclen = node->simdclone->vecsize_int;
else
veclen = node->simdclone->vecsize_float;
- veclen /= GET_MODE_BITSIZE (TYPE_MODE (t));
+ veclen /= GET_MODE_BITSIZE (SCALAR_TYPE_MODE (t));
if (veclen > node->simdclone->simdlen)
veclen = node->simdclone->simdlen;
if (POINTER_TYPE_P (t))
@@ -606,7 +606,7 @@ simd_clone_adjust_argument_types (struct cgraph_node *node)
veclen = sc->vecsize_int;
else
veclen = sc->vecsize_float;
- veclen /= GET_MODE_BITSIZE (TYPE_MODE (parm_type));
+ veclen /= GET_MODE_BITSIZE (SCALAR_TYPE_MODE (parm_type));
if (veclen > sc->simdlen)
veclen = sc->simdlen;
adj.arg_prefix = "simd";
@@ -650,7 +650,7 @@ simd_clone_adjust_argument_types (struct cgraph_node *node)
veclen = sc->vecsize_int;
else
veclen = sc->vecsize_float;
- veclen /= GET_MODE_BITSIZE (TYPE_MODE (base_type));
+ veclen /= GET_MODE_BITSIZE (SCALAR_TYPE_MODE (base_type));
if (veclen > sc->simdlen)
veclen = sc->simdlen;
if (sc->mask_mode != VOIDmode)
@@ -792,8 +792,8 @@ simd_clone_init_simd_arrays (struct cgraph_node *node,
arg = DECL_CHAIN (arg);
j++;
}
- elemsize
- = GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (TREE_TYPE (arg))));
+ tree elemtype = TREE_TYPE (TREE_TYPE (arg));
+ elemsize = GET_MODE_SIZE (SCALAR_TYPE_MODE (elemtype));
tree t = build2 (MEM_REF, TREE_TYPE (arg), ptr,
build_int_cst (ptype, k * elemsize));
t = build2 (MODIFY_EXPR, TREE_TYPE (t), t, arg);
@@ -1226,7 +1226,7 @@ simd_clone_adjust (struct cgraph_node *node)
mask_array, iter1, NULL, NULL);
g = gimple_build_assign (mask, aref);
gsi_insert_after (&gsi, g, GSI_CONTINUE_LINKING);
- int bitsize = GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (aref)));
+ int bitsize = GET_MODE_BITSIZE (SCALAR_TYPE_MODE (TREE_TYPE (aref)));
if (!INTEGRAL_TYPE_P (TREE_TYPE (aref)))
{
aref = build1 (VIEW_CONVERT_EXPR,
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index 012602d..d6c1bb6 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -2219,10 +2219,13 @@ layout_type (tree type)
}
case FIXED_POINT_TYPE:
- /* TYPE_MODE (type) has been set already. */
- TYPE_SIZE (type) = bitsize_int (GET_MODE_BITSIZE (TYPE_MODE (type)));
- TYPE_SIZE_UNIT (type) = size_int (GET_MODE_SIZE (TYPE_MODE (type)));
- break;
+ {
+ /* TYPE_MODE (type) has been set already. */
+ scalar_mode mode = SCALAR_TYPE_MODE (type);
+ TYPE_SIZE (type) = bitsize_int (GET_MODE_BITSIZE (mode));
+ TYPE_SIZE_UNIT (type) = size_int (GET_MODE_SIZE (mode));
+ break;
+ }
case COMPLEX_TYPE:
TYPE_UNSIGNED (type) = TYPE_UNSIGNED (TREE_TYPE (type));
@@ -2243,7 +2246,8 @@ layout_type (tree type)
/* Find an appropriate mode for the vector type. */
if (TYPE_MODE (type) == VOIDmode)
SET_TYPE_MODE (type,
- mode_for_vector (TYPE_MODE (innertype), nunits));
+ mode_for_vector (SCALAR_TYPE_MODE (innertype),
+ nunits));
TYPE_SATURATING (type) = TYPE_SATURATING (TREE_TYPE (type));
TYPE_UNSIGNED (type) = TYPE_UNSIGNED (TREE_TYPE (type));
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index c156b81..b759306 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -4192,7 +4192,7 @@ verify_gimple_assign_ternary (gassign *stmt)
if (TREE_CODE (TREE_TYPE (rhs3_type)) != INTEGER_TYPE
|| GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (rhs3_type)))
- != GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (rhs1_type))))
+ != GET_MODE_BITSIZE (SCALAR_TYPE_MODE (TREE_TYPE (rhs1_type))))
{
error ("invalid mask type in vector permute expression");
debug_generic_expr (lhs_type);
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 1652f2f..cce5dc7 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -3879,7 +3879,7 @@ estimate_move_cost (tree type, bool ARG_UNUSED (speed_p))
if (TREE_CODE (type) == VECTOR_TYPE)
{
- machine_mode inner = TYPE_MODE (TREE_TYPE (type));
+ scalar_mode inner = SCALAR_TYPE_MODE (TREE_TYPE (type));
machine_mode simd
= targetm.vectorize.preferred_simd_mode (inner);
int simd_mode_size = GET_MODE_SIZE (simd);
diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c
index 86a1559..818290c 100644
--- a/gcc/tree-ssa-math-opts.c
+++ b/gcc/tree-ssa-math-opts.c
@@ -3350,7 +3350,8 @@ convert_plusminus_to_widen (gimple_stmt_iterator *gsi, gimple *stmt,
optab this_optab;
enum tree_code wmult_code;
enum insn_code handler;
- machine_mode to_mode, from_mode, actual_mode;
+ scalar_mode to_mode, from_mode;
+ machine_mode actual_mode;
location_t loc = gimple_location (stmt);
int actual_precision;
bool from_unsigned1, from_unsigned2;
@@ -3446,8 +3447,8 @@ convert_plusminus_to_widen (gimple_stmt_iterator *gsi, gimple *stmt,
else
return false;
- to_mode = TYPE_MODE (type);
- from_mode = TYPE_MODE (type1);
+ to_mode = SCALAR_TYPE_MODE (type);
+ from_mode = SCALAR_TYPE_MODE (type1);
from_unsigned1 = TYPE_UNSIGNED (type1);
from_unsigned2 = TYPE_UNSIGNED (type2);
optype = type1;
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 59e41f6..5a1d9ff 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -4809,7 +4809,8 @@ vect_create_epilog_for_reduction (vec<tree> vect_defs, gimple *stmt,
(index_vec_type);
/* Get an unsigned integer version of the type of the data vector. */
- int scalar_precision = GET_MODE_PRECISION (TYPE_MODE (scalar_type));
+ int scalar_precision
+ = GET_MODE_PRECISION (SCALAR_TYPE_MODE (scalar_type));
tree scalar_type_unsigned = make_unsigned_type (scalar_precision);
tree vectype_unsigned = build_vector_type
(scalar_type_unsigned, TYPE_VECTOR_SUBPARTS (vectype));
@@ -6211,7 +6212,8 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
}
else
{
- int scalar_precision = GET_MODE_PRECISION (TYPE_MODE (scalar_type));
+ int scalar_precision
+ = GET_MODE_PRECISION (SCALAR_TYPE_MODE (scalar_type));
cr_index_scalar_type = make_unsigned_type (scalar_precision);
cr_index_vector_type = build_vector_type
(cr_index_scalar_type, TYPE_VECTOR_SUBPARTS (vectype_out));
diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c
index 6bc4f7e..4fee7a8 100644
--- a/gcc/tree-vect-patterns.c
+++ b/gcc/tree-vect-patterns.c
@@ -939,8 +939,8 @@ vect_recog_widen_mult_pattern (vec<gimple *> *stmts,
tree itype = type;
if (TYPE_PRECISION (type) > TYPE_PRECISION (half_type0) * 2)
itype = build_nonstandard_integer_type
- (GET_MODE_BITSIZE (TYPE_MODE (half_type0)) * 2,
- TYPE_UNSIGNED (type));
+ (GET_MODE_BITSIZE (SCALAR_TYPE_MODE (half_type0)) * 2,
+ TYPE_UNSIGNED (type));
/* Pattern detected. */
if (dump_enabled_p ())
@@ -3083,7 +3083,7 @@ vect_recog_mixed_size_cond_pattern (vec<gimple *> *stmts, tree *type_in,
TYPE_UNSIGNED (type));
if (itype == NULL_TREE
- || GET_MODE_BITSIZE (TYPE_MODE (itype)) != cmp_mode_size)
+ || GET_MODE_BITSIZE (SCALAR_TYPE_MODE (itype)) != cmp_mode_size)
return NULL;
vecitype = get_vectype_for_scalar_type (itype);
@@ -3200,7 +3200,7 @@ check_bool_pattern (tree var, vec_info *vinfo, hash_set<gimple *> &stmts)
if (TREE_CODE (TREE_TYPE (rhs1)) != INTEGER_TYPE)
{
- machine_mode mode = TYPE_MODE (TREE_TYPE (rhs1));
+ scalar_mode mode = SCALAR_TYPE_MODE (TREE_TYPE (rhs1));
tree itype
= build_nonstandard_integer_type (GET_MODE_BITSIZE (mode), 1);
vecitype = get_vectype_for_scalar_type (itype);
@@ -3322,7 +3322,7 @@ adjust_bool_pattern (tree var, tree out_type,
irhs1 = *defs.get (rhs1);
tree def_rhs1 = gimple_assign_rhs1 (def_stmt);
if (TYPE_PRECISION (TREE_TYPE (irhs1))
- == GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (def_rhs1))))
+ == GET_MODE_BITSIZE (SCALAR_TYPE_MODE (TREE_TYPE (def_rhs1))))
{
rhs_code = def_rhs_code;
rhs1 = def_rhs1;
@@ -3341,7 +3341,7 @@ adjust_bool_pattern (tree var, tree out_type,
irhs2 = *defs.get (rhs2);
tree def_rhs1 = gimple_assign_rhs1 (def_stmt);
if (TYPE_PRECISION (TREE_TYPE (irhs2))
- == GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (def_rhs1))))
+ == GET_MODE_BITSIZE (SCALAR_TYPE_MODE (TREE_TYPE (def_rhs1))))
{
rhs_code = def_rhs_code;
rhs1 = def_rhs1;
@@ -3391,7 +3391,7 @@ adjust_bool_pattern (tree var, tree out_type,
|| (TYPE_PRECISION (TREE_TYPE (rhs1))
!= GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (rhs1)))))
{
- machine_mode mode = TYPE_MODE (TREE_TYPE (rhs1));
+ scalar_mode mode = SCALAR_TYPE_MODE (TREE_TYPE (rhs1));
itype
= build_nonstandard_integer_type (GET_MODE_BITSIZE (mode), 1);
}
@@ -3544,7 +3544,7 @@ search_type_for_mask_1 (tree var, vec_info *vinfo,
if (TREE_CODE (TREE_TYPE (rhs1)) != INTEGER_TYPE
|| !TYPE_UNSIGNED (TREE_TYPE (rhs1)))
{
- machine_mode mode = TYPE_MODE (TREE_TYPE (rhs1));
+ scalar_mode mode = SCALAR_TYPE_MODE (TREE_TYPE (rhs1));
res = build_nonstandard_integer_type (GET_MODE_BITSIZE (mode), 1);
}
else
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index 08746b4..3873893 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -3754,7 +3754,7 @@ vect_schedule_slp_instance (slp_tree node, slp_instance instance,
v1 = SLP_TREE_VEC_STMTS (node).copy ();
SLP_TREE_VEC_STMTS (node).truncate (0);
tree meltype = build_nonstandard_integer_type
- (GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (vectype))), 1);
+ (GET_MODE_BITSIZE (SCALAR_TYPE_MODE (TREE_TYPE (vectype))), 1);
tree mvectype = get_same_sized_vectype (meltype, vectype);
unsigned k = 0, l;
for (j = 0; j < v0.length (); ++j)
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 96606bd..e17918a 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -4070,7 +4070,6 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi,
vec<tree> interm_types = vNULL;
tree last_oprnd, intermediate_type, cvt_type = NULL_TREE;
int op_type;
- machine_mode rhs_mode;
unsigned short fltsz;
/* Is STMT a vectorizable conversion? */
@@ -4213,6 +4212,9 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi,
needs to be generated. */
gcc_assert (ncopies >= 1);
+ machine_mode lhs_mode = SCALAR_TYPE_MODE (lhs_type);
+ machine_mode rhs_mode = SCALAR_TYPE_MODE (rhs_type);
+
/* Supportable by target? */
switch (modifier)
{
@@ -4241,12 +4243,11 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi,
}
if (code != FLOAT_EXPR
- || (GET_MODE_SIZE (TYPE_MODE (lhs_type))
- <= GET_MODE_SIZE (TYPE_MODE (rhs_type))))
+ || GET_MODE_SIZE (lhs_mode) <= GET_MODE_SIZE (rhs_mode))
goto unsupported;
- fltsz = GET_MODE_SIZE (TYPE_MODE (lhs_type));
- FOR_EACH_2XWIDER_MODE (rhs_mode, TYPE_MODE (rhs_type))
+ fltsz = GET_MODE_SIZE (lhs_mode);
+ FOR_EACH_2XWIDER_MODE (rhs_mode, rhs_mode)
{
if (GET_MODE_SIZE (rhs_mode) > fltsz)
break;
@@ -4298,11 +4299,9 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi,
break;
if (code != FIX_TRUNC_EXPR
- || (GET_MODE_SIZE (TYPE_MODE (lhs_type))
- >= GET_MODE_SIZE (TYPE_MODE (rhs_type))))
+ || GET_MODE_SIZE (lhs_mode) >= GET_MODE_SIZE (rhs_mode))
goto unsupported;
- rhs_mode = TYPE_MODE (rhs_type);
cvt_type
= build_nonstandard_integer_type (GET_MODE_BITSIZE (rhs_mode), 0);
cvt_type = get_same_sized_vectype (cvt_type, vectype_in);
@@ -6026,7 +6025,7 @@ vectorizable_store (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
/* First check if vec_extract optab doesn't support extraction
of vector elts directly. */
- machine_mode elmode = TYPE_MODE (elem_type);
+ scalar_mode elmode = SCALAR_TYPE_MODE (elem_type);
machine_mode vmode = mode_for_vector (elmode, group_size);
if (! VECTOR_MODE_P (vmode)
|| (convert_optab_handler (vec_extract_optab,
@@ -7064,7 +7063,7 @@ vectorizable_load (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
{
/* First check if vec_init optab supports construction from
vector elts directly. */
- machine_mode elmode = TYPE_MODE (TREE_TYPE (vectype));
+ scalar_mode elmode = SCALAR_TYPE_MODE (TREE_TYPE (vectype));
machine_mode vmode = mode_for_vector (elmode, group_size);
if (VECTOR_MODE_P (vmode)
&& (convert_optab_handler (vec_init_optab,
diff --git a/gcc/tree.c b/gcc/tree.c
index 92a32c8..0420808 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -2132,8 +2132,9 @@ build_minus_one_cst (tree type)
case FIXED_POINT_TYPE:
/* We can only generate 1 for accum types. */
gcc_assert (ALL_SCALAR_ACCUM_MODE_P (TYPE_MODE (type)));
- return build_fixed (type, fixed_from_double_int (double_int_minus_one,
- TYPE_MODE (type)));
+ return build_fixed (type,
+ fixed_from_double_int (double_int_minus_one,
+ SCALAR_TYPE_MODE (type)));
case VECTOR_TYPE:
{
diff --git a/gcc/tree.h b/gcc/tree.h
index 8347669..19dd807 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -1849,6 +1849,8 @@ extern void protected_set_expr_location (tree, location_t);
#define TYPE_MODE(NODE) \
(VECTOR_TYPE_P (TYPE_CHECK (NODE)) \
? vector_type_mode (NODE) : (NODE)->type_common.mode)
+#define SCALAR_TYPE_MODE(NODE) \
+ (as_a <scalar_mode> (TYPE_CHECK (NODE)->type_common.mode))
#define SCALAR_INT_TYPE_MODE(NODE) \
(as_a <scalar_int_mode> (TYPE_CHECK (NODE)->type_common.mode))
#define SCALAR_FLOAT_TYPE_MODE(NODE) \
diff --git a/gcc/ubsan.c b/gcc/ubsan.c
index 9b2083f..1030168 100644
--- a/gcc/ubsan.c
+++ b/gcc/ubsan.c
@@ -124,7 +124,8 @@ tree
ubsan_encode_value (tree t, enum ubsan_encode_value_phase phase)
{
tree type = TREE_TYPE (t);
- const unsigned int bitsize = GET_MODE_BITSIZE (TYPE_MODE (type));
+ scalar_mode mode = SCALAR_TYPE_MODE (type);
+ const unsigned int bitsize = GET_MODE_BITSIZE (mode);
if (bitsize <= POINTER_SIZE)
switch (TREE_CODE (type))
{
@@ -161,10 +162,8 @@ ubsan_encode_value (tree t, enum ubsan_encode_value_phase phase)
}
if (phase == UBSAN_ENCODE_VALUE_RTL)
{
- rtx mem
- = assign_stack_temp_for_type (TYPE_MODE (type),
- GET_MODE_SIZE (TYPE_MODE (type)),
- type);
+ rtx mem = assign_stack_temp_for_type (mode, GET_MODE_SIZE (mode),
+ type);
SET_DECL_RTL (var, mem);
expand_assignment (var, t, false);
return build_fold_addr_expr (var);
diff --git a/gcc/varasm.c b/gcc/varasm.c
index f10f26eb..adf99fb 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -4885,7 +4885,7 @@ output_constant (tree exp, unsigned HOST_WIDE_INT size, unsigned int align,
break;
case VECTOR_CST:
{
- machine_mode inner = TYPE_MODE (TREE_TYPE (TREE_TYPE (exp)));
+ scalar_mode inner = SCALAR_TYPE_MODE (TREE_TYPE (TREE_TYPE (exp)));
unsigned int nalign = MIN (align, GET_MODE_ALIGNMENT (inner));
int elt_size = GET_MODE_SIZE (inner);
output_constant (VECTOR_CST_ELT (exp, 0), elt_size, align,