From patchwork Mon Mar 25 10:56:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Zissulescu Ianculescu X-Patchwork-Id: 1064127 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-498368-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="uvVRnIT2"; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="buq4qUBp"; 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 44SWRv2zTKz9sSM for ; Mon, 25 Mar 2019 21:57:10 +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:mime-version :content-transfer-encoding; q=dns; s=default; b=MKnLeLN+ntRw0t/G S7wh+Tr28QiV+Rhe+dQoj/H5F/BJU6fo52CrIdGDuwrzc5r5yI2b2J9fiV9CoJv5 P/gduUpa15pyPDzs45bCfU2cHHfpTxzWleLEFeKFhveJKRBvqH5i0+yfmuGKLQJO 4kBW1IvuU19jw5mGyPKKBrHQUBI= 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:mime-version :content-transfer-encoding; s=default; bh=1DbiVanDRLiI6lA9ashfRS aqpy8=; b=uvVRnIT2FHOI2TWXy4+U2HEIhAYorMgGMKw5IASpcfcFSUEHGF0Pqn DonpAETB7eLEoueOI+bCI8gaG7D5HVhg0l1HcmrsS1ktzmj/IAr3hajL0u+WGUUi v8CeQGVTnleguttXNZHiI3ixZTIPPH8rv20lIkVoFzl3QFTAsg4VI= Received: (qmail 82377 invoked by alias); 25 Mar 2019 10:57:01 -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 82363 invoked by uid 89); 25 Mar 2019 10:57:00 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-13.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, 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=UD:B, Defining, nb, gty X-HELO: mail-ed1-f47.google.com Received: from mail-ed1-f47.google.com (HELO mail-ed1-f47.google.com) (209.85.208.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 25 Mar 2019 10:56:59 +0000 Received: by mail-ed1-f47.google.com with SMTP id q3so7116616edg.0 for ; Mon, 25 Mar 2019 03:56:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=bpDoqvfmSA3HrMH6OWmhyrbI2lFFS5VobaaFwXVQAzM=; b=buq4qUBphq8u10lz1oUAAQgtq8MBJ7OdbsxNGsA1KwQRUzQLDiCse0qzdHisE0PJo1 PQbq79K0WFzhlukBXBlE4z0D5NZ4TgzvApIqVfWTj9yWY6sZYm+2yRMSYLMfctumyPrb 6VDLnspiXTw2duFpvqJ/Sp+TKdkr7gOfnITmyt+Z2Vx5s0x3pHdjfOv/N4sYe5kIiMSt vDLejd5yNbukaq+Baof83Ca54V3Ap3wwg/6EZJMyR+fNbeh/xHa5vlzfoXrd9QFhsQ2Y Qm0gN7AfNcKB3NdZaNfUcDoQc6q96boJwOY4+W2pjQlfGmbYaVQ2Urs3AHELxQakdl3Z mu+w== Received: from engy.ddns.hightechcampus.nl ([80.255.245.234]) by smtp.gmail.com with ESMTPSA id q3sm1745093edr.31.2019.03.25.03.56.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Mar 2019 03:56:56 -0700 (PDT) From: Claudiu Zissulescu To: gcc-patches@gcc.gnu.org Cc: fbedard@synopsys.com, andrew.burgess@embecosm.com Subject: [PATCH] [ARC] Restore blink first when optimizing for speed. Date: Mon, 25 Mar 2019 11:56:49 +0100 Message-Id: <20190325105649.9142-1-claziss@gmail.com> MIME-Version: 1.0 X-IsSubscribed: yes Hi, When not optimizing for size, we can restore first blink, hence the return instruction will be executed faster. OK to apply? Claudiu gcc/ xxxx-xx-xx Claudiu Zissulescu * config/arc/arc.c (GMASK_LEN): Define. (arc_restore_callee_saves): Restore first blink when !optimize_size. --- gcc/config/arc/arc.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c index de2c8d5df9c..9a6920a709f 100644 --- a/gcc/config/arc/arc.c +++ b/gcc/config/arc/arc.c @@ -2545,6 +2545,9 @@ struct GTY (()) arc_frame_info bool save_return_addr; }; +/* GMASK bit length -1. */ +#define GMASK_LEN 31 + /* Defining data structures for per-function information. */ typedef struct GTY (()) machine_function @@ -3087,6 +3090,8 @@ arc_restore_callee_saves (unsigned int gmask, { rtx reg; int frame_deallocated = 0; + HOST_WIDE_INT offs = cfun->machine->frame_info.reg_size; + bool early_blink_restore; /* Emit mov fp,sp. */ if (arc_frame_pointer_needed () && offset) @@ -3112,9 +3117,21 @@ arc_restore_callee_saves (unsigned int gmask, offset = 0; } + /* When we do not optimize for size, restore first blink. */ + early_blink_restore = restore_blink && !optimize_size && offs; + if (early_blink_restore) + { + rtx addr = plus_constant (Pmode, stack_pointer_rtx, offs); + reg = gen_rtx_REG (Pmode, RETURN_ADDR_REGNUM); + rtx insn = frame_move_inc (reg, gen_frame_mem (Pmode, addr), + stack_pointer_rtx, NULL_RTX); + add_reg_note (insn, REG_CFA_RESTORE, reg); + restore_blink = false; + } + /* N.B. FRAME_POINTER_MASK and RETURN_ADDR_MASK are cleared in gmask. */ if (gmask) - for (int i = 0; i <= 31; i++) + for (int i = 0; i <= GMASK_LEN; i++) { machine_mode restore_mode = SImode; @@ -3127,7 +3144,23 @@ arc_restore_callee_saves (unsigned int gmask, continue; reg = gen_rtx_REG (restore_mode, i); - frame_deallocated += frame_restore_reg (reg, 0); + offs = 0; + switch (restore_mode) + { + case E_DImode: + if ((GMASK_LEN - __builtin_clz (gmask)) == (i + 1) + && early_blink_restore) + offs = 4; + break; + case E_SImode: + if ((GMASK_LEN - __builtin_clz (gmask)) == i + && early_blink_restore) + offs = 4; + break; + default: + offs = 0; + } + frame_deallocated += frame_restore_reg (reg, offs); offset = 0; if (restore_mode == DImode)