From patchwork Thu Jul 13 08:56:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107637 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1938609qge; Thu, 13 Jul 2017 01:58:24 -0700 (PDT) X-Received: by 10.98.79.130 with SMTP id f2mr60517717pfj.133.1499936304210; Thu, 13 Jul 2017 01:58:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936304; cv=none; d=google.com; s=arc-20160816; b=s7RmmixdyDnUAa6XJqxD87xKDW5qZnsXunFT3QzaY8KtWBcYFD9k/yYMEvMaXvHtu0 ZRb+R/O2XhxcOWgrOnIwrCDmsX4jJhXX2TgJ8rZDeBcqhWuTWHYK/RRoystbfs0k6v2V otyJoGlD5GLLm0mc1yt+/QZA0+CzQq84Wj0v88AzzqGwAyQS4DJBjF+3+k0KPF61Waan 9eW+peD9SfZnU/UEsr7mNE03WsaTaxKx0mpXJ4VqjOYaETOd2DWVPlLbergwHZGLgJSc fWCKHl8bNDum7iMNAI8+wPrU4rg9S3CZxwe+2hn2GBclLJk3d10G21BPtgqO9klXDuaz sPxA== 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=uz8MrBJ6Rc29vj4ZCz2H9f4Jv0jCbj3g2iofJbCim/I=; b=AAJPQkbB9SaK0lUpzeD/v6tsePj8KKN6b1UgG6ekA/AyuchFsWdhMP2YwweeSBVr8a nOA9RHi3bcwtJF3vyP9Z/speWT60kKj5i/0fgk+NjfsZQOkYf7fCZXFrFc2sz4UZpJ67 OoFtv/06xPJpQksoScbXEXX8a32UAKJrgHYLDk2PvbRTOLjo4q4rofZ9uByg0dLj69Y6 SB0fUPtSeB8yZiuuOltlqNyXOUFYGsrTTxwEBHP3urAggP1hnY9rh6QoOhzLpDFMpTAC Vj2FZXK0X+lT7dswX7lGep9/aYvcxjJ3h6cwoZU47Y8/pVi9jk7gkMJmJqQGWViH5/Ov LGaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=UBiRUD5b; spf=pass (google.com: domain of gcc-patches-return-458042-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458042-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 w9si3790582pfk.85.2017.07.13.01.58.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:58:24 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458042-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=UBiRUD5b; spf=pass (google.com: domain of gcc-patches-return-458042-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458042-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=Z9ywAq4x4zThN4+Giegp8OwOoMpst GQt/XJiUQ02pzruHCS095t09hhYKvrZ0tfz5/SO6ThkOFWF53C9VD0AseYDk5zgJ yEqV8rJDfB9rh5gVTN5iU203MJRp5MYjbRvcmp/D8DeTZJA+QqEfznII9cw3ADRX 24HeQrYiGn1UzA= 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=LZiQv98bZqjho0w2SvBL0CIhdpw=; b=UBi RUD5bfEgHBcTl/U/6b3860VDQNMsuXBZU5PvHiUMxDjN+wxE0ZjcSrQ3DgB/lJ5x Utm6AoOO2hMkQhv+XCtpzx9FxybZDeX/DQIA9B6Rgav3+S1IsWAJEcFv4aLOxweY f4Hp57p6HizxLrO7Pn9hwbsQk5ASHo2gKjQVOrvo= Received: (qmail 30354 invoked by alias); 13 Jul 2017 08:56:35 -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 29518 invoked by uid 89); 13 Jul 2017 08:56:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-15.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_1, 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-f48.google.com Received: from mail-wm0-f48.google.com (HELO mail-wm0-f48.google.com) (74.125.82.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:56:30 +0000 Received: by mail-wm0-f48.google.com with SMTP id w126so16749119wme.0 for ; Thu, 13 Jul 2017 01:56:29 -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=uz8MrBJ6Rc29vj4ZCz2H9f4Jv0jCbj3g2iofJbCim/I=; b=fpwxMqejn+Cc1Ue8uNpDBNCiZ86iH6w/Azra5dvdPv5cvRdQcf0kS4DExY+CX8/Sri 7afspaEkh/9O3lsRStJlKBkd5ODUxNYKYccCoBUyQ5WJv5mg2k1xRrWho7nHqpNQEzds CkKrCkoOpy8IKFR1qBaXDHSx97Q1Ei7nRlFSYo0Lo7S5ZCs1MJ3C2FnBwLK1uYhBOYXP 3KYA8ubMOz4zwBWdLpFD6v60/g2EtYhaI2KpPFH2x7iQ5PSWq58hxvXoeTjo5i382tnC lFWh8tFuLNd8psn5oi9d7okt7vfD76iSGPiAGeScbHDIkHvgo8akcJoXIuJ7ha6RFV/P U8tg== X-Gm-Message-State: AIVw111jH2OW4WR+tbhYH+XhRRX7PJcekTXWh7ucsG3lozGDItbQp0BE sWzXP4vvd17qZQriS2VzKw== X-Received: by 10.28.95.137 with SMTP id t131mr1162317wmb.102.1499936187448; Thu, 13 Jul 2017 01:56:27 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id 1sm5429235wmn.32.2017.07.13.01.56.26 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:56:26 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [51/77] Use opt_scalar_int_mode when iterating over integer modes References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:56:24 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <871spkg1fr.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch uses opt_scalar_int_mode rather than machine_mode when iterating over scalar_int_modes, in cases where that helps with future patches. (Using machine_mode is still OK in places that don't really care about the mode being a scalar integer.) 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * cse.c (cse_insn): Use opt_scalar_int_mode for the mode iterator. * explow.c (hard_function_value): Likewise. * expmed.c (init_expmed_one_mode): Likewise. (extract_fixed_bit_field_1): Likewise. Move the convert_to_mode call outside the loop. * expr.c (alignment_for_piecewise_move): Use opt_scalar_int_mode for the mode iterator. Require the mode specified by max_pieces to exist. (emit_block_move_via_movmem): Use opt_scalar_int_mode for the mode iterator. (copy_blkmode_to_reg): Likewise. (set_storage_via_setmem): Likewise. * optabs.c (prepare_cmp_insn): Likewise. * rtlanal.c (init_num_sign_bit_copies_in_rep): Likewise. * stor-layout.c (finish_bitfield_representative): Likewise. gcc/fortran/ * trans-types.c (gfc_init_kinds): Use opt_scalar_int_mode for the mode iterator. Index: gcc/cse.c =================================================================== --- gcc/cse.c 2017-07-13 09:18:39.584734236 +0100 +++ gcc/cse.c 2017-07-13 09:18:46.699153232 +0100 @@ -4885,11 +4885,12 @@ cse_insn (rtx_insn *insn) && GET_CODE (src) == AND && CONST_INT_P (XEXP (src, 1)) && GET_MODE_SIZE (int_mode) < UNITS_PER_WORD) { - machine_mode tmode; + opt_scalar_int_mode tmode_iter; rtx new_and = gen_rtx_AND (VOIDmode, NULL_RTX, XEXP (src, 1)); - FOR_EACH_WIDER_MODE (tmode, int_mode) + FOR_EACH_WIDER_MODE (tmode_iter, int_mode) { + scalar_int_mode tmode = *tmode_iter; if (GET_MODE_SIZE (tmode) > UNITS_PER_WORD) break; @@ -4932,7 +4933,6 @@ cse_insn (rtx_insn *insn) { struct rtx_def memory_extend_buf; rtx memory_extend_rtx = &memory_extend_buf; - machine_mode tmode; /* Set what we are trying to extend and the operation it might have been extended with. */ @@ -4940,10 +4940,12 @@ cse_insn (rtx_insn *insn) PUT_CODE (memory_extend_rtx, extend_op); XEXP (memory_extend_rtx, 0) = src; - FOR_EACH_WIDER_MODE (tmode, int_mode) + opt_scalar_int_mode tmode_iter; + FOR_EACH_WIDER_MODE (tmode_iter, int_mode) { struct table_elt *larger_elt; + scalar_int_mode tmode = *tmode_iter; if (GET_MODE_SIZE (tmode) > UNITS_PER_WORD) break; Index: gcc/explow.c =================================================================== --- gcc/explow.c 2017-07-13 09:18:21.531429258 +0100 +++ gcc/explow.c 2017-07-13 09:18:46.700153153 +0100 @@ -1906,7 +1906,7 @@ hard_function_value (const_tree valtype, && GET_MODE (val) == BLKmode) { unsigned HOST_WIDE_INT bytes = int_size_in_bytes (valtype); - machine_mode tmpmode; + opt_scalar_int_mode tmpmode; /* int_size_in_bytes can return -1. We don't need a check here since the value of bytes will then be large enough that no @@ -1915,14 +1915,11 @@ hard_function_value (const_tree valtype, FOR_EACH_MODE_IN_CLASS (tmpmode, MODE_INT) { /* Have we found a large enough mode? */ - if (GET_MODE_SIZE (tmpmode) >= bytes) + if (GET_MODE_SIZE (*tmpmode) >= bytes) break; } - /* No suitable mode found. */ - gcc_assert (tmpmode != VOIDmode); - - PUT_MODE (val, tmpmode); + PUT_MODE (val, *tmpmode); } return val; } Index: gcc/expmed.c =================================================================== --- gcc/expmed.c 2017-07-13 09:18:42.161519072 +0100 +++ gcc/expmed.c 2017-07-13 09:18:46.700153153 +0100 @@ -147,7 +147,6 @@ init_expmed_one_mode (struct init_expmed machine_mode mode, int speed) { int m, n, mode_bitsize; - machine_mode mode_from; mode_bitsize = GET_MODE_UNIT_BITSIZE (mode); @@ -205,8 +204,9 @@ init_expmed_one_mode (struct init_expmed scalar_int_mode int_mode_to; if (is_a (mode, &int_mode_to)) { - FOR_EACH_MODE_IN_CLASS (mode_from, MODE_INT) - init_expmed_one_conv (all, int_mode_to, mode_from, speed); + opt_scalar_int_mode int_mode_from; + FOR_EACH_MODE_IN_CLASS (int_mode_from, MODE_INT) + init_expmed_one_conv (all, int_mode_to, *int_mode_from, speed); scalar_int_mode wider_mode; if (GET_MODE_CLASS (int_mode_to) == MODE_INT @@ -2019,12 +2019,13 @@ extract_fixed_bit_field_1 (machine_mode /* Find the narrowest integer mode that contains the field. */ - FOR_EACH_MODE_IN_CLASS (mode, MODE_INT) - if (GET_MODE_BITSIZE (mode) >= bitsize + bitnum) - { - op0 = convert_to_mode (mode, op0, 0); - break; - } + opt_scalar_int_mode mode_iter; + FOR_EACH_MODE_IN_CLASS (mode_iter, MODE_INT) + if (GET_MODE_BITSIZE (*mode_iter) >= bitsize + bitnum) + break; + + mode = *mode_iter; + op0 = convert_to_mode (mode, op0, 0); if (mode != tmode) target = 0; Index: gcc/expr.c =================================================================== --- gcc/expr.c 2017-07-13 09:18:46.226190608 +0100 +++ gcc/expr.c 2017-07-13 09:18:46.702152995 +0100 @@ -699,18 +699,17 @@ convert_modes (machine_mode mode, machin static unsigned int alignment_for_piecewise_move (unsigned int max_pieces, unsigned int align) { - machine_mode tmode; + scalar_int_mode tmode = *int_mode_for_size (max_pieces * BITS_PER_UNIT, 1); - tmode = mode_for_size (max_pieces * BITS_PER_UNIT, MODE_INT, 1); if (align >= GET_MODE_ALIGNMENT (tmode)) align = GET_MODE_ALIGNMENT (tmode); else { - machine_mode tmode, xmode; - - xmode = NARROWEST_INT_MODE; - FOR_EACH_MODE_IN_CLASS (tmode, MODE_INT) + scalar_int_mode xmode = NARROWEST_INT_MODE; + opt_scalar_int_mode mode_iter; + FOR_EACH_MODE_IN_CLASS (mode_iter, MODE_INT) { + tmode = *mode_iter; if (GET_MODE_SIZE (tmode) > max_pieces || SLOW_UNALIGNED_ACCESS (tmode, align)) break; @@ -1707,7 +1706,6 @@ emit_block_move_via_movmem (rtx x, rtx y unsigned HOST_WIDE_INT probable_max_size) { int save_volatile_ok = volatile_ok; - machine_mode mode; if (expected_align < align) expected_align = align; @@ -1726,8 +1724,10 @@ emit_block_move_via_movmem (rtx x, rtx y including more than one in the machine description unless the more limited one has some advantage. */ - FOR_EACH_MODE_IN_CLASS (mode, MODE_INT) + opt_scalar_int_mode mode_iter; + FOR_EACH_MODE_IN_CLASS (mode_iter, MODE_INT) { + scalar_int_mode mode = *mode_iter; enum insn_code code = direct_optab_handler (movmem_optab, mode); if (code != CODE_FOR_nothing @@ -2791,13 +2791,13 @@ copy_blkmode_to_reg (machine_mode mode, { /* Find the smallest integer mode large enough to hold the entire structure. */ - FOR_EACH_MODE_IN_CLASS (mode, MODE_INT) - /* Have we found a large enough mode? */ - if (GET_MODE_SIZE (mode) >= bytes) + opt_scalar_int_mode mode_iter; + FOR_EACH_MODE_IN_CLASS (mode_iter, MODE_INT) + if (GET_MODE_SIZE (*mode_iter) >= bytes) break; /* A suitable mode should have been found. */ - gcc_assert (mode != VOIDmode); + mode = *mode_iter; } if (GET_MODE_SIZE (mode) < GET_MODE_SIZE (word_mode)) @@ -3035,8 +3035,6 @@ set_storage_via_setmem (rtx object, rtx including more than one in the machine description unless the more limited one has some advantage. */ - machine_mode mode; - if (expected_align < align) expected_align = align; if (expected_size != -1) @@ -3047,8 +3045,10 @@ set_storage_via_setmem (rtx object, rtx expected_size = min_size; } - FOR_EACH_MODE_IN_CLASS (mode, MODE_INT) + opt_scalar_int_mode mode_iter; + FOR_EACH_MODE_IN_CLASS (mode_iter, MODE_INT) { + scalar_int_mode mode = *mode_iter; enum insn_code code = direct_optab_handler (setmem_optab, mode); if (code != CODE_FOR_nothing Index: gcc/optabs.c =================================================================== --- gcc/optabs.c 2017-07-13 09:18:39.591733644 +0100 +++ gcc/optabs.c 2017-07-13 09:18:46.703152916 +0100 @@ -3799,8 +3799,10 @@ prepare_cmp_insn (rtx x, rtx y, enum rtx /* Try to use a memory block compare insn - either cmpstr or cmpmem will do. */ - FOR_EACH_MODE_IN_CLASS (cmp_mode, MODE_INT) + opt_scalar_int_mode cmp_mode_iter; + FOR_EACH_MODE_IN_CLASS (cmp_mode_iter, MODE_INT) { + scalar_int_mode cmp_mode = *cmp_mode_iter; cmp_code = direct_optab_handler (cmpmem_optab, cmp_mode); if (cmp_code == CODE_FOR_nothing) cmp_code = direct_optab_handler (cmpstr_optab, cmp_mode); Index: gcc/rtlanal.c =================================================================== --- gcc/rtlanal.c 2017-07-13 09:18:45.762227456 +0100 +++ gcc/rtlanal.c 2017-07-13 09:18:46.703152916 +0100 @@ -5660,12 +5660,14 @@ get_condition (rtx_insn *jump, rtx_insn static void init_num_sign_bit_copies_in_rep (void) { - machine_mode mode, in_mode; + opt_scalar_int_mode in_mode_iter; + scalar_int_mode mode; - FOR_EACH_MODE_IN_CLASS (in_mode, MODE_INT) - FOR_EACH_MODE_UNTIL (mode, in_mode) + FOR_EACH_MODE_IN_CLASS (in_mode_iter, MODE_INT) + FOR_EACH_MODE_UNTIL (mode, *in_mode_iter) { - machine_mode i; + scalar_int_mode in_mode = *in_mode_iter; + scalar_int_mode i; /* Currently, it is assumed that TARGET_MODE_REP_EXTENDED extends to the next widest mode. */ @@ -5678,7 +5680,7 @@ init_num_sign_bit_copies_in_rep (void) { /* This must always exist (for the last iteration it will be IN_MODE). */ - machine_mode wider = *GET_MODE_WIDER_MODE (i); + scalar_int_mode wider = *GET_MODE_WIDER_MODE (i); if (targetm.mode_rep_extended (i, wider) == SIGN_EXTEND /* We can only check sign-bit copies starting from the Index: gcc/stor-layout.c =================================================================== --- gcc/stor-layout.c 2017-07-13 09:18:41.680558844 +0100 +++ gcc/stor-layout.c 2017-07-13 09:18:46.704152837 +0100 @@ -1827,7 +1827,6 @@ start_bitfield_representative (tree fiel finish_bitfield_representative (tree repr, tree field) { unsigned HOST_WIDE_INT bitsize, maxbitsize; - machine_mode mode; tree nextf, size; size = size_diffop (DECL_FIELD_OFFSET (field), @@ -1892,15 +1891,15 @@ finish_bitfield_representative (tree rep gcc_assert (maxbitsize % BITS_PER_UNIT == 0); /* Find the smallest nice mode to use. */ - FOR_EACH_MODE_IN_CLASS (mode, MODE_INT) - if (GET_MODE_BITSIZE (mode) >= bitsize) + opt_scalar_int_mode mode_iter; + FOR_EACH_MODE_IN_CLASS (mode_iter, MODE_INT) + if (GET_MODE_BITSIZE (*mode_iter) >= bitsize) break; - if (mode != VOIDmode - && (GET_MODE_BITSIZE (mode) > maxbitsize - || GET_MODE_BITSIZE (mode) > MAX_FIXED_MODE_SIZE)) - mode = VOIDmode; - if (mode == VOIDmode) + scalar_int_mode mode; + if (!mode_iter.exists (&mode) + || GET_MODE_BITSIZE (mode) > maxbitsize + || GET_MODE_BITSIZE (mode) > MAX_FIXED_MODE_SIZE) { /* We really want a BLKmode representative only as a last resort, considering the member b in Index: gcc/fortran/trans-types.c =================================================================== --- gcc/fortran/trans-types.c 2017-07-13 09:18:32.525352977 +0100 +++ gcc/fortran/trans-types.c 2017-07-13 09:18:46.702152995 +0100 @@ -362,15 +362,16 @@ #define NAMED_SUBROUTINE(a,b,c,d) \ void gfc_init_kinds (void) { - machine_mode mode; + opt_scalar_int_mode int_mode_iter; opt_scalar_float_mode float_mode_iter; int i_index, r_index, kind; bool saw_i4 = false, saw_i8 = false; bool saw_r4 = false, saw_r8 = false, saw_r10 = false, saw_r16 = false; - for (i_index = 0, mode = MIN_MODE_INT; mode <= MAX_MODE_INT; - mode = (machine_mode) ((int) mode + 1)) + i_index = 0; + FOR_EACH_MODE_IN_CLASS (int_mode_iter, MODE_INT) { + scalar_int_mode mode = *int_mode_iter; int kind, bitsize; if (!targetm.scalar_mode_supported_p (mode))