From patchwork Sat Feb 8 22:02:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Wilson X-Patchwork-Id: 1235391 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-519181-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=maJeOIhZ; dkim=pass (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.a=rsa-sha256 header.s=google header.b=C0ai0khl; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48FR4V2r0Qz9sPJ for ; Sun, 9 Feb 2020 09:03:04 +1100 (AEDT) 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:cc:subject:date:message-id; q=dns; s=default; b=K5+p5QSjJHMn lq3ko9mKe7LqYV4XbA4xSKQlI/izz8nUDEkzOOtOzkLAs9yrkrrjzfBFnE3kuQ4K 0Ae54ELql6mH90F3St15jnvsoHqpP5EegK1hdw52OJkrP3Dq3dJ8QqebrJz3DiBT XY4Uv6oIA8IOmhPuxoB4zztwTBiwqR0= 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:cc:subject:date:message-id; s=default; bh=RXW32jgT0e8NUsUEvN om+f0CxHk=; b=maJeOIhZuGErz7nf1DaPws/+NRzpmN4R38sIMP40l67O6xhjZM AKC22PZzQXE4rNpUrPhLWvuxWgaJOrU0feER52uxUzi5J0MBoH9xnnirz5KEKDfk nPmmah4ldldrSmDigcvRZwhEbjR/SqOZv/Qr5IvQSuD0IlKRRCx+HM1ww= Received: (qmail 130501 invoked by alias); 8 Feb 2020 22:02:56 -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 130492 invoked by uid 89); 8 Feb 2020 22:02:55 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=nregs X-HELO: mail-pj1-f42.google.com Received: from mail-pj1-f42.google.com (HELO mail-pj1-f42.google.com) (209.85.216.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 08 Feb 2020 22:02:54 +0000 Received: by mail-pj1-f42.google.com with SMTP id n96so2478316pjc.3 for ; Sat, 08 Feb 2020 14:02:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id; bh=93P9h+rOC//zBQF3SzgSlrmLWwHT+HaPNB5Ju4HDGZM=; b=C0ai0khlf1MB67TwMmGXSref6iD3Q6BAou70iA5Xitpe8BN5HhM+vQFuF86Dm2frL1 CSC9eKPVQ1ddQEqndEG0gLoPnPq05SQP++Y5/XVZW3qMG2hgB0z5nAGHy+/WWvCyquVs 6DUuyuG2Oowa3XzlFWGxacpJ1T/OyZZObkLdR7qIiKesrJllnxfdfkSCWpVJxIFyb8Ox MwJE81vl8Eha2SU5slkbONzlTnoYCRrL5amXvMaWDKSGNB48C8k80uQC7/KuWSW7wM7L sBgzIaZQs8HU4mfiHiyXb7O8aWnntuAVUIRVOEA1lJ6Krk8BaaodolviXE7g41tj0gDe GxTA== Received: from rohan.hsd1.ca.comcast.net ([2601:646:c180:b150:9076:2a06:bff2:ba81]) by smtp.gmail.com with ESMTPSA id q17sm7438215pfg.123.2020.02.08.14.02.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Feb 2020 14:02:52 -0800 (PST) From: Jim Wilson To: gcc-patches@gcc.gnu.org Cc: Jim Wilson Subject: [committed] RISC-V: Improve caller-save code generation. Date: Sat, 8 Feb 2020 14:02:49 -0800 Message-Id: <20200208220249.20503-1-jimw@sifive.com> X-IsSubscribed: yes Avoid paradoxical subregs when caller save. This reduces stack frame size due to smaller loads and stores, and more frequent rematerialization. Tested with cross riscv32-elf and riscv64-linux build and check, with no regressions. Committed. Jim PR target/93532 * config/riscv/riscv.h (HARD_REGNO_CALLER_SAVE_MODE): Define. --- gcc/config/riscv/riscv.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h index 19438e28fe8..567c23380fe 100644 --- a/gcc/config/riscv/riscv.h +++ b/gcc/config/riscv/riscv.h @@ -268,6 +268,13 @@ along with GCC; see the file COPYING3. If not see 1, 1 \ } +/* Select a register mode required for caller save of hard regno REGNO. + Contrary to what is documented, the default is not the smallest suitable + mode but the largest suitable mode for the given (REGNO, NREGS) pair and + it quickly creates paradoxical subregs that can be problematic. */ +#define HARD_REGNO_CALLER_SAVE_MODE(REGNO, NREGS, MODE) \ + ((MODE) == VOIDmode ? choose_hard_reg_mode (REGNO, NREGS, NULL) : (MODE)) + /* Internal macros to classify an ISA register's type. */ #define GP_REG_FIRST 0