From patchwork Thu Jul 13 09:01:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107651 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1944132qge; Thu, 13 Jul 2017 02:04:01 -0700 (PDT) X-Received: by 10.98.83.130 with SMTP id h124mr34537405pfb.13.1499936641485; Thu, 13 Jul 2017 02:04:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936641; cv=none; d=google.com; s=arc-20160816; b=Pf79/mdcQm1VKXOZsJ7vVV9xebFJVZHpRm5N9ciF/eOYmosJ01ExMQbQeLHLjA1RGi 0tcayH2xa5HLbctdHVeOsvGT3IvUeprxOh++4Q72XQrzwAWZlqv3MqbxE880fijE6Gw2 BnapyvvaJA/ZPZWBMO3bPVw+xsPOz82cCfS7AKjmGg7ex0aXb6/u8m9AYdOoaq9P6HU9 mZdky7O7OWiRI5TRedPWHWsd3r8DwG/bYoKaHM1nZpYWG21Jl1rHLWySqp5oNtaM9Veg iClLnjlkprpBYdn4on7j5AhvXgiWBHgoF+zI6DW/NQ4XpzyqNVvm+5sQeazjYpvbd0bN N48w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:mail-followup-to:to:from:delivered-to:sender:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=XqMB/bf04V1VdmG+vjJvPZ76BW12Px+8FJr/paxQ1Fk=; b=skqVOPC2aLqqtuAiDmLdvboJos3yAbPXt3qXZhq+SIMXbDSsX5VjUKZlYw1JXnEeKQ SNM9IuZaFelCjjcOz+O71fVPopdFuvYbEonr3gcb9P9f0bUdnBLI25xqxJQRmI8ZgRi4 tR8HA5paM+ZNykoAFwGBsfzcuzF6J45+F3/Kwva0Bt2BHrMj8Q0o7DVKR+XPQlkt7FQA Zk+f8pLLbOBmLma84rN6rcadppPlGGeSe7tJgO75V/gHpj3f0zbNsSEhNr3i0ADupv6Z 2SFuJiCo3CYU2lRvBf3g5cscYWtEpHUp2o8FdVk7kevdAVGd6TvXGl3GYeFwhT55Eoe6 6saQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=axrVflry; spf=pass (google.com: domain of gcc-patches-return-458056-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458056-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id 3si1354838plt.599.2017.07.13.02.04.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 02:04:01 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458056-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=axrVflry; spf=pass (google.com: domain of gcc-patches-return-458056-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458056-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=default; b=BvCqXQ0CGIRXM0Lh2ZtQIlwhNIi+b NmGhAaHWSWJ1AA5J+sFbjhK6DiBWLlYOZyz7XAX6xqmpBbLmZNfsAYYDCwE+9qXo 4uObn+fJyYVZq/FUbHv/n5tP7fKiB56yHgAm1OoONO7J5dNcOBW+LgyFfAvf4nxk BBIfu9KTHFSNOU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:references:date:in-reply-to:message-id:mime-version :content-type; s=default; bh=PqEpRRUd989XGc8edf9Z/fkSYtM=; b=axr Vflryneu1HndIR3x06DkIhWwtISE5rywEx+bHpLD28QNCNVAlgWyruQDLU7V3OiI L+jGOpPlszrEii+AZs34Os/O8G4rffbHa+02VI1OBLrm2LyZCJgg2Svr5Ok8/2v9 gjwqHtc5z8WIiD9vNytFRJaf0qV2Q3cn/RBOPSyo= Received: (qmail 95471 invoked by alias); 13 Jul 2017 09:02:15 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 94333 invoked by uid 89); 13 Jul 2017 09:02:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f51.google.com Received: from mail-wm0-f51.google.com (HELO mail-wm0-f51.google.com) (74.125.82.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 09:01:52 +0000 Received: by mail-wm0-f51.google.com with SMTP id 62so16928697wmw.1 for ; Thu, 13 Jul 2017 02:01:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:mail-followup-to:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=XqMB/bf04V1VdmG+vjJvPZ76BW12Px+8FJr/paxQ1Fk=; b=H1naDpGFxAxjlrb9QrloT/+eXJPZUY6cCUdu0FEdXaq7WxEZTOjCN+OYuv5ec3JxSL YQ+w4PFqIDm5KAlOBZU15nnxEZ8lN+4qyTPFDkK8/6s9ZxBhhkUN1it2T6j/Ahahg8jo sp/FaikeJvJJ46u/GZj6OLha+93OsZCrt4UVyDUI0I13wc5AWZNuKAfswAyoHS+XAi8h 9Xm5vgnhWL70XdDEucZdZq2E/Vqf+eBGMX8fPu/HmF2v8+t99VzNmLLT/8m/ITA1iJnb Ll4knIkpyuc6RRxH7IbFYjfO0XV1PAURnjKw18Jn2tsyGvybZjcH7zu/7Xvr/nPyAegv uHOg== X-Gm-Message-State: AIVw1107S9mMS/8Lx0w1n7y5EhKwbFIx5tO5NH6LE4NlBAyWM6zmUzmY 5ZdtlrEYiEX0yxX6DieBDA== X-Received: by 10.28.232.133 with SMTP id f5mr1282240wmi.46.1499936509835; Thu, 13 Jul 2017 02:01:49 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id b83sm3061374wmh.30.2017.07.13.02.01.48 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 02:01:49 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [65/77] Add a SCALAR_TYPE_MODE macro References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 10:01:47 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87d194d81w.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 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 to c_common_type, when converting an unsigned fixed-point SCALAR_TYPE_MODE to the equivalent signed mode. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood 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. * 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 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. Index: gcc/tree.h =================================================================== --- gcc/tree.h 2017-07-13 09:18:38.668812030 +0100 +++ gcc/tree.h 2017-07-13 09:18:54.005596227 +0100 @@ -1852,6 +1852,8 @@ #define TYPE_MODE_RAW(NODE) (TYPE_CHECK #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 (TYPE_CHECK (NODE)->type_common.mode)) #define SCALAR_INT_TYPE_MODE(NODE) \ (as_a (TYPE_CHECK (NODE)->type_common.mode)) #define SCALAR_FLOAT_TYPE_MODE(NODE) \ Index: gcc/expr.c =================================================================== --- gcc/expr.c 2017-07-13 09:18:53.273650396 +0100 +++ gcc/expr.c 2017-07-13 09:18:53.997596816 +0100 @@ -7758,7 +7758,7 @@ expand_expr_addr_expr_1 (tree exp, rtx t 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; @@ -9436,7 +9436,7 @@ #define REDUCE_BIT_FIELD(expr) (reduce_b { 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); Index: gcc/fold-const.c =================================================================== --- gcc/fold-const.c 2017-07-13 09:18:51.658771072 +0100 +++ gcc/fold-const.c 2017-07-13 09:18:53.998596742 +0100 @@ -2058,8 +2058,8 @@ fold_convert_const_fixed_from_fixed (tre 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. */ @@ -2087,7 +2087,7 @@ fold_convert_const_fixed_from_int (tree 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); @@ -2108,7 +2108,7 @@ fold_convert_const_fixed_from_real (tree 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); @@ -7115,7 +7115,7 @@ native_encode_int (const_tree expr, unsi 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; @@ -7217,7 +7217,7 @@ native_encode_complex (const_tree expr, 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) @@ -7241,7 +7241,7 @@ native_encode_vector (const_tree expr, u 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) @@ -7369,7 +7369,8 @@ native_interpret_int (tree type, const u 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; @@ -7378,7 +7379,7 @@ native_interpret_fixed (tree type, const 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); } @@ -7400,7 +7401,6 @@ native_interpret_real (tree type, const 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; @@ -7455,7 +7455,7 @@ native_interpret_complex (tree type, con 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); @@ -7480,7 +7480,7 @@ native_interpret_vector (tree type, cons 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; Index: gcc/omp-simd-clone.c =================================================================== --- gcc/omp-simd-clone.c 2017-06-30 12:50:38.645644151 +0100 +++ gcc/omp-simd-clone.c 2017-07-13 09:18:53.998596742 +0100 @@ -495,7 +495,7 @@ simd_clone_adjust_return_type (struct cg 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)) @@ -605,7 +605,7 @@ simd_clone_adjust_argument_types (struct 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"; @@ -649,7 +649,7 @@ simd_clone_adjust_argument_types (struct 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) @@ -791,8 +791,8 @@ simd_clone_init_simd_arrays (struct cgra 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); @@ -1225,7 +1225,7 @@ simd_clone_adjust (struct cgraph_node *n 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, Index: gcc/stor-layout.c =================================================================== --- gcc/stor-layout.c 2017-07-13 09:18:51.664770620 +0100 +++ gcc/stor-layout.c 2017-07-13 09:18:53.998596742 +0100 @@ -2155,10 +2155,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)); @@ -2179,7 +2182,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)); Index: gcc/tree.c =================================================================== --- gcc/tree.c 2017-07-13 09:18:39.596733221 +0100 +++ gcc/tree.c 2017-07-13 09:18:54.004596300 +0100 @@ -2128,8 +2128,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: { Index: gcc/tree-cfg.c =================================================================== --- gcc/tree-cfg.c 2017-07-13 09:18:38.664812372 +0100 +++ gcc/tree-cfg.c 2017-07-13 09:18:53.999596668 +0100 @@ -4190,7 +4190,7 @@ verify_gimple_assign_ternary (gassign *s 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); Index: gcc/tree-inline.c =================================================================== --- gcc/tree-inline.c 2017-07-02 09:32:32.660745273 +0100 +++ gcc/tree-inline.c 2017-07-13 09:18:54.000596593 +0100 @@ -3871,7 +3871,7 @@ estimate_move_cost (tree type, bool ARG_ 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); Index: gcc/tree-ssa-math-opts.c =================================================================== --- gcc/tree-ssa-math-opts.c 2017-07-13 09:18:38.664812372 +0100 +++ gcc/tree-ssa-math-opts.c 2017-07-13 09:18:54.000596593 +0100 @@ -3227,7 +3227,8 @@ convert_plusminus_to_widen (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; @@ -3323,8 +3324,8 @@ convert_plusminus_to_widen (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; Index: gcc/tree-vect-loop.c =================================================================== --- gcc/tree-vect-loop.c 2017-07-13 09:17:19.693324483 +0100 +++ gcc/tree-vect-loop.c 2017-07-13 09:18:54.001596521 +0100 @@ -4745,7 +4745,8 @@ vect_create_epilog_for_reduction (vec 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< 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 * 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_ 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_ 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_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_in 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 Index: gcc/tree-vect-slp.c =================================================================== --- gcc/tree-vect-slp.c 2017-07-13 09:18:30.088577124 +0100 +++ gcc/tree-vect-slp.c 2017-07-13 09:18:54.002596447 +0100 @@ -3685,7 +3685,7 @@ vect_schedule_slp_instance (slp_tree nod 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) Index: gcc/tree-vect-stmts.c =================================================================== --- gcc/tree-vect-stmts.c 2017-07-13 09:18:30.090576938 +0100 +++ gcc/tree-vect-stmts.c 2017-07-13 09:18:54.003596374 +0100 @@ -4051,7 +4051,6 @@ vectorizable_conversion (gimple *stmt, g vec 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? */ @@ -4196,6 +4195,9 @@ vectorizable_conversion (gimple *stmt, g 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) { @@ -4224,12 +4226,11 @@ vectorizable_conversion (gimple *stmt, g } 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; @@ -4281,11 +4282,9 @@ vectorizable_conversion (gimple *stmt, g 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); Index: gcc/ubsan.c =================================================================== --- gcc/ubsan.c 2017-07-13 09:18:38.668812030 +0100 +++ gcc/ubsan.c 2017-07-13 09:18:54.005596227 +0100 @@ -120,7 +120,8 @@ decl_for_type_insert (tree type, tree de 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)) { @@ -157,10 +158,8 @@ ubsan_encode_value (tree t, enum ubsan_e } 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); Index: gcc/varasm.c =================================================================== --- gcc/varasm.c 2017-07-13 09:18:53.276650175 +0100 +++ gcc/varasm.c 2017-07-13 09:18:54.006596154 +0100 @@ -4837,7 +4837,7 @@ output_constant (tree exp, unsigned HOST 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, Index: gcc/c-family/c-lex.c =================================================================== --- gcc/c-family/c-lex.c 2017-02-23 19:54:03.000000000 +0000 +++ gcc/c-family/c-lex.c 2017-07-13 09:18:53.993597112 +0100 @@ -1109,7 +1109,7 @@ interpret_fixed (const cpp_token *token, 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); Index: gcc/c-family/c-common.c =================================================================== --- gcc/c-family/c-common.c 2017-07-13 09:18:39.582734406 +0100 +++ gcc/c-family/c-common.c 2017-07-13 09:18:53.993597112 +0100 @@ -1031,8 +1031,8 @@ c_build_vec_perm_expr (location_t loc, t 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 " Index: gcc/c/c-typeck.c =================================================================== --- gcc/c/c-typeck.c 2017-06-16 07:48:59.558141760 +0100 +++ gcc/c/c-typeck.c 2017-07-13 09:18:53.995596964 +0100 @@ -810,11 +810,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)) @@ -846,7 +846,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 + (mode_for_size (GET_MODE_PRECISION (m1), mclass, 0)); } if (code2 == FIXED_POINT_TYPE && TYPE_UNSIGNED (t2)) { @@ -857,7 +858,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 + (mode_for_size (GET_MODE_PRECISION (m2), mclass, 0)); } } @@ -11306,7 +11308,8 @@ build_binary_op (location_t location, en /* 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; @@ -11465,7 +11468,8 @@ build_binary_op (location_t location, en /* 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; Index: gcc/cp/typeck.c =================================================================== --- gcc/cp/typeck.c 2017-06-30 12:50:38.117668481 +0100 +++ gcc/cp/typeck.c 2017-07-13 09:18:53.996596890 +0100 @@ -4950,8 +4950,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)