From patchwork Thu Jul 13 08:54:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107632 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1936998qge; Thu, 13 Jul 2017 01:56:13 -0700 (PDT) X-Received: by 10.84.232.197 with SMTP id x5mr8946431plm.159.1499936173842; Thu, 13 Jul 2017 01:56:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936173; cv=none; d=google.com; s=arc-20160816; b=NeILYBr2yLE1M+mKbl4B+V29J2qBD5LDUs9jshIi00TCPlRlkWR7b9krFj29P77Y/R bIajKf66CRsMnLyBWEL6g2ROK8mV18/iIhrBgBn9zIVNsK+H4Eif9oT9xxu4Ik0wjWLF nwccTTQ/UkGY6dSLKigNCJZwYTpk8VzQwiDrA+2auZ8PrC6inpFxJYHW7ocOofgFC74j cLYfRNAphKOpTti7AJf9hEVTcUCyJrLfW3r82dRImArA/xlWv0Tm2BHz0c751tJGuhxh YDIzXgI77qs2eVLz5SJWKMwbefJzZJ8FP/zplqFqWaCSJ5I25l3ifWR8HTJVXZbvtDJo SvhA== 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=Mr7EAMiIb/5Nezt9vKaAudQ0gaXhJyJgWKIBgXX6kRg=; b=nOt6ty/P6GYtw0TkgqIJbo+ZWKVkg+91bThN6CdAXVELRcjAZOe84CcZqsVUogMgeS T4cPHPRkEhM+67nxxUsyvLQVYZI6Lj72d50krgwI0GAvHV482o4fQavSGsABC5P9THnV xc62hQsHjkATcgxee5PP6DZZOJ9tb10DXQ3fqzPPy9h9qjRGrAUXv1jH0FBDZNjWwlBA ahzLA82y2KRc8aQnx0Rymi7S1Ki9/M2+s932aZ79IP5Hxkhgi31JMa/M65sN9nZ91cJA c2RgrhqgJHaC39JU1ix0qHyDcr1f6UnFsvvju68j56H4EhOZkD7qR1JpFl1/wNkJfzEk 3/PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=iGJtAcTd; spf=pass (google.com: domain of gcc-patches-return-458037-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458037-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 c19si3902908pgk.501.2017.07.13.01.56.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:56:13 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458037-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=iGJtAcTd; spf=pass (google.com: domain of gcc-patches-return-458037-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458037-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=uFjtb227fA5bCzN4ZbHVvWC387yXy hV20yIss33QLpZ9x/93X057k6YNeR4qLFG84lxKDAvChfQkufI5CknRP4rtFr+nQ wQdjlCteugHNupJxobAFlSirq5Y0OEE/KuCUEcUsOphEypsYPW/fT8kPAT8DWw55 l/eEKB5CAnrulk= 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=3WRAkKcy13YYxFHRmkANqFYDLpc=; b=iGJ tAcTdPn6S0ZwOuD1Ws4gPkxP/2Ax9kbBbwMtSxxe85RWABdMCaM5LWbYHXphmnvu CyAe702JZmZPEkR+9lHl7UMlBbcvd5fYLSJLhdvYNZYvIBrmbaMmn9UizpjSq4ea rbRemr4WdaM7eiytzFzePfFSYQzJ56qSapifQmmI= Received: (qmail 70185 invoked by alias); 13 Jul 2017 08:54:59 -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 69338 invoked by uid 89); 13 Jul 2017 08:54:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr0-f170.google.com Received: from mail-wr0-f170.google.com (HELO mail-wr0-f170.google.com) (209.85.128.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:54:54 +0000 Received: by mail-wr0-f170.google.com with SMTP id r103so49590508wrb.0 for ; Thu, 13 Jul 2017 01:54:53 -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=Mr7EAMiIb/5Nezt9vKaAudQ0gaXhJyJgWKIBgXX6kRg=; b=cSXlk8N/VZqjmCTPGwlzZQ0mS7ZhCk+ttsV/69sFrxmt0RDjZaEGclcOmoPvJiElQu KrzSGkZtJmRudQwRKTXLyXGdymZCpKUdx+uCUdGkwgxVhe2mLqy4YcmWK8LzYtGIhoeF Xt+3Ie3WnCM6Inq1XMpOoUdVshvTwdWVSW0FBm+DGgD86EUAgTTChDDpYY3Kc4fqDcYZ xXlN9a5jyWVRKMac4wtFuP+I4fIwXNAfzqZZh3WN4tNbLmuQ+cQuWnW3Usp4W+CV8cfL b9795UB+4Bsg1y266hPMt1aR6bu3W5QovGrxjEtKhDupAQ5dxYW8YitWkgmf4XL1U+yx MMKQ== X-Gm-Message-State: AIVw113uddqeFAsqIu3Vf4NKjiaEtrmsEmwRl+JyhaCFZCj3MxMZfr7d mXtZP4s9h05nnAwRhU4mWQ== X-Received: by 10.223.163.135 with SMTP id l7mr898071wrb.88.1499936092095; Thu, 13 Jul 2017 01:54:52 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id 143sm5825851wmg.9.2017.07.13.01.54.51 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:54:51 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [46/77] Make widest_int_mode_for_size return a scalar_int_mode References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:54:50 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87mv88g1id.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 The comment for widest_int_mode said that it returns "the widest integer mode no wider than SIZE", but it actually returns the widest integer mode that is narrower than SIZE. In practice SIZE is always greater than 1, so it can always pick QImode in the worst case. The VOIDmode paths seem to be dead. gcc/ 2017-07-13 Richard Sandiford Alan Hayward David Sherwood * expr.c (widest_int_mode_for_size): Make the comment match the code. Return a scalar_int_mode and assert that the size is greater than one byte. (by_pieces_ninsns): Update accordingly and remove VOIDmode handling. (op_by_pieces_d::op_by_pieces_d): Likewise. (op_by_pieces_d::run): Likewise. (can_store_by_pieces): Likewise. Index: gcc/expr.c =================================================================== --- gcc/expr.c 2017-07-13 09:18:41.678559010 +0100 +++ gcc/expr.c 2017-07-13 09:18:44.578322246 +0100 @@ -722,19 +722,21 @@ alignment_for_piecewise_move (unsigned i return align; } -/* Return the widest integer mode no wider than SIZE. If no such mode - can be found, return VOIDmode. */ +/* Return the widest integer mode that is narrower than SIZE bytes. */ -static machine_mode +static scalar_int_mode widest_int_mode_for_size (unsigned int size) { - machine_mode tmode, mode = VOIDmode; + scalar_int_mode result = NARROWEST_INT_MODE; + gcc_checking_assert (size > 1); + + opt_scalar_int_mode tmode; FOR_EACH_MODE_IN_CLASS (tmode, MODE_INT) - if (GET_MODE_SIZE (tmode) < size) - mode = tmode; + if (GET_MODE_SIZE (*tmode) < size) + result = *tmode; - return mode; + return result; } /* Determine whether an operation OP on LEN bytes with alignment ALIGN can @@ -771,13 +773,9 @@ by_pieces_ninsns (unsigned HOST_WIDE_INT while (max_size > 1 && l > 0) { - machine_mode mode; + scalar_int_mode mode = widest_int_mode_for_size (max_size); enum insn_code icode; - mode = widest_int_mode_for_size (max_size); - - if (mode == VOIDmode) - break; unsigned int modesize = GET_MODE_SIZE (mode); icode = optab_handler (mov_optab, mode); @@ -1053,7 +1051,7 @@ op_by_pieces_d::op_by_pieces_d (rtx to, if (by_pieces_ninsns (len, align, m_max_size, MOVE_BY_PIECES) > 2) { /* Find the mode of the largest comparison. */ - machine_mode mode = widest_int_mode_for_size (m_max_size); + scalar_int_mode mode = widest_int_mode_for_size (m_max_size); m_from.decide_autoinc (mode, m_reverse, len); m_to.decide_autoinc (mode, m_reverse, len); @@ -1073,10 +1071,7 @@ op_by_pieces_d::run () { while (m_max_size > 1 && m_len > 0) { - machine_mode mode = widest_int_mode_for_size (m_max_size); - - if (mode == VOIDmode) - break; + scalar_int_mode mode = widest_int_mode_for_size (m_max_size); if (prepare_mode (mode, m_align)) { @@ -1287,7 +1282,6 @@ can_store_by_pieces (unsigned HOST_WIDE_ unsigned HOST_WIDE_INT l; unsigned int max_size; HOST_WIDE_INT offset = 0; - machine_mode mode; enum insn_code icode; int reverse; /* cst is set but not used if LEGITIMATE_CONSTANT doesn't use it. */ @@ -1316,10 +1310,7 @@ can_store_by_pieces (unsigned HOST_WIDE_ max_size = STORE_MAX_PIECES + 1; while (max_size > 1 && l > 0) { - mode = widest_int_mode_for_size (max_size); - - if (mode == VOIDmode) - break; + scalar_int_mode mode = widest_int_mode_for_size (max_size); icode = optab_handler (mov_optab, mode); if (icode != CODE_FOR_nothing