From patchwork Mon Aug 21 11:14:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 110517 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp1127566qge; Mon, 21 Aug 2017 04:14:37 -0700 (PDT) X-Received: by 10.84.131.71 with SMTP id 65mr18544245pld.35.1503314077061; Mon, 21 Aug 2017 04:14:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503314077; cv=none; d=google.com; s=arc-20160816; b=tSGbV24SP8W5wWVa9Js17f5Mm2XCAB2ngm7OIrUiQLie8dtIzJiCLmUSk2XCdE1zkD 6yRswXuc+jR6J8HWggu4mbO0fCpSzKqvv1mNqofbLFSDV6Uts98g/gUCkXyynUZSdRVk l1mJHeHQ+npe+NfvrR+B7gU+ASs4kO+apzU8iKbKKYdJ+XzEOq5jP27A2jeahPvIHFWs 1o/BOJMY6+TCDjipg/AU7KZ9MAtvKV5159gRoiTtvPPFSF8YZxDfswkzq6HYRR5ZKEEb SVVwA1h+jl1YZepy0qAVlO7B/xMj9CurTj+IRccQtlG94IvTHEaaz8OWfJAUdFIXGiyr FACg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:date: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=qfF+UjuRWn4O5na+BwBruVK8lF7PK3+LT/2GmpbrXJI=; b=0YoOPr8lv+kas4rL9UL5lCGSY5J6XGD2+DG4BYG/5lY9GT4/bfR/FD3eYxw+frG9c+ GuAGTFwzKiIxXmAGbU8tyZNKgULwLXFux90AdR3q2E6h8qUSXIkYyvXiHDnKhc0zUQ8Y AYJXQ79Cx5de1hkWR7rVqIzHQPd0BNeY2VZlRXyuxDeMlDLZz862EFh6gOHAKjXwzfPN yLANJEmCh/r0jEdrTTu6kUAA7XBOXkGUVrCFxMWetttNxwEJYBnYZiXUMP0i88sztJC+ RrCChgrbbsVRe61rXbtQlZgoRplw9/k/ONIFUWUBmLv8Hl7vI8OvDE5M5XrwpN8/Ds1s c/yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=T57Pr8W7; spf=pass (google.com: domain of gcc-patches-return-460631-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-460631-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 u194si7023864pgc.468.2017.08.21.04.14.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Aug 2017 04:14:37 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-460631-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.s=default header.b=T57Pr8W7; spf=pass (google.com: domain of gcc-patches-return-460631-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-460631-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:date:message-id:mime-version:content-type; q=dns; s= default; b=UU0SsIKNYBylIz3YPwL2EJ/FvwV7uzMHcPC/ahKEPOUnWp6nfTNX8 XWsCO9BLu7vNeIsboIXC9ugaDn8TSYKYt8EcYAXNoXa5RwAMVH6aQMGLHTxTvL9y 7vzpvDcuU/A+X4yJyVhxZxCJxnOu84mYmyUnJeGT+mI0Dqc6hgdicY= 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:date:message-id:mime-version:content-type; s= default; bh=HAtnTDedLFHWM3Uv8EDo86M1QNE=; b=T57Pr8W7Exk5YABwQgE8 GkeJpq/jSQaP357RCWln64elX7RDuLvienyLlIFNJWjrKDXiNLXsZongM/JprDei k/++fOEfRqQb7e9IpmAP18q9asP9MJsLM+ppU8+wHEMdxoWJXZpcLsq+wNgdj4E/ dOZCwoYxZBcA2qUZ5Df05ug= Received: (qmail 106113 invoked by alias); 21 Aug 2017 11:14:23 -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 103572 invoked by uid 89); 21 Aug 2017 11:14:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-9.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, RCVD_IN_SORBS_WEB, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr0-f172.google.com Received: from mail-wr0-f172.google.com (HELO mail-wr0-f172.google.com) (209.85.128.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 21 Aug 2017 11:14:20 +0000 Received: by mail-wr0-f172.google.com with SMTP id z91so94589264wrc.4 for ; Mon, 21 Aug 2017 04:14:19 -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:date:message-id :user-agent:mime-version; bh=qfF+UjuRWn4O5na+BwBruVK8lF7PK3+LT/2GmpbrXJI=; b=tt4gkkX/1g4IRWPbWxX5QPS9ICO5KODHVmqSylR8nm5HMZAQSad3JUfLoSkaE5P7r8 6eVkVHMEgYt8d0xBXG7hFL6wa4V9CuGUIIeFWrTzpiKyGI6UFBMfZ6lUCLaZ9TFWwR8P 6hLsd6PQELUYhH9OABdKcDWp3450WHN2TYtlC9Gw2wVwTzIuxttNfqIlHkEFdntiec0y hm8lw81qOWJ14YKsefIIS4rDi2qmDCnMGThuzl0Q6JFdb1WPugAwA0cPqdiPQpc6JGAY RhsS2/0nkCBc8DdfNjY7wWsoSvYG7tVNDHtRWG+h/2uFQ2T9+KAU01XJgIYooDU7odyV 2+hg== X-Gm-Message-State: AHYfb5iQBfth2Jy3M3xgn1rA8AG/LiaY2uCNtcJTlxst9GvNXvAYZC0j snIEz45srLB+nY8kXB/kNA== X-Received: by 10.223.179.196 with SMTP id x4mr9998283wrd.86.1503314057704; Mon, 21 Aug 2017 04:14:17 -0700 (PDT) Received: from localhost (92.40.248.206.threembb.co.uk. [92.40.248.206]) by smtp.gmail.com with ESMTPSA id 40sm4386150wrz.8.2017.08.21.04.14.16 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Aug 2017 04:14:16 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: Simplify pad_below implementation Date: Mon, 21 Aug 2017 12:14:11 +0100 Message-ID: <874lt1dvgc.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch simplifies the alignment calculations in pad_below. The first arm of the "if" was: - taking GET_MODE_BITSIZE (always equal to GET_MODE_SIZE * BITS_PER_UNIT), - rounding up to the next multiple of PARM_BOUNDARY - converting bits to bytes and - subtracting the GET_MODE_SIZE so was in effect calculating the number of bytes needed to round GET_MODE_SIZE up to (PARM_BOUNDARY / BITS_PER_UNIT). That can be done more directly as -size & (align - 1), which is easier to convert to variable-sized modes. Tested on aarch64-linux-gnu and x86_64-linux-gnu, and by building one target per CPU and checking that there were no differences in assembly for the testsuite. OK to install? Richard 2017-08-21 Richard Sandiford Alan Hayward David Sherwood gcc/ * function.c (pad_below): Simplify padding calculation. Index: gcc/function.c =================================================================== --- gcc/function.c 2017-08-21 10:42:34.185530464 +0100 +++ gcc/function.c 2017-08-21 11:55:41.018148268 +0100 @@ -4322,21 +4322,16 @@ pad_to_arg_alignment (struct args_size * static void pad_below (struct args_size *offset_ptr, machine_mode passed_mode, tree sizetree) { + unsigned int align = PARM_BOUNDARY / BITS_PER_UNIT; if (passed_mode != BLKmode) - { - if (GET_MODE_BITSIZE (passed_mode) % PARM_BOUNDARY) - offset_ptr->constant - += (((GET_MODE_BITSIZE (passed_mode) + PARM_BOUNDARY - 1) - / PARM_BOUNDARY * PARM_BOUNDARY / BITS_PER_UNIT) - - GET_MODE_SIZE (passed_mode)); - } + offset_ptr->constant += -GET_MODE_SIZE (passed_mode) & (align - 1); else { if (TREE_CODE (sizetree) != INTEGER_CST - || (TREE_INT_CST_LOW (sizetree) * BITS_PER_UNIT) % PARM_BOUNDARY) + || (TREE_INT_CST_LOW (sizetree) & (align - 1)) != 0) { /* Round the size up to multiple of PARM_BOUNDARY bits. */ - tree s2 = round_up (sizetree, PARM_BOUNDARY / BITS_PER_UNIT); + tree s2 = round_up (sizetree, align); /* Add it in. */ ADD_PARM_SIZE (*offset_ptr, s2); SUB_PARM_SIZE (*offset_ptr, sizetree);