From patchwork Tue Jan 16 03:04:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Wilson X-Patchwork-Id: 861199 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-471325-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="T8Kub3kG"; 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 3zLFSL68tQz9ryr for ; Tue, 16 Jan 2018 14:04:33 +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=CFoXtjZou+4J jXkH6NIsYUWpfZb8kUVGFLvjTqdr1d24HUh/ypGUPgjuHX8B1odTNXmAlbHeLu7W KBo9DFjujYMh2Vj/pTZlluodRhuXeFwZ4E+v1QB9IQLHr2VCFIhugtKcw5KVxL9P UjTG7H4hBF3ImNUrvjdOpwUH2i9hCT8= 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=tSLchGeFsEVb5fkEAF f0GE0cmyc=; b=T8Kub3kGZ4Ckj56iV1IQIrMQkjWDH3J4WYTLfwbxGLquNfGYuo KZkm+U8a1VifMoYqrXjT8syDKLbOYAkQcAI5OZRBRKUQGPb6wRJKwVhO6vPe5/B/ VVlgSKWD27jzS96kLApaPvCWYZLI3OmyHZ1vTyp60OqoHiJkjrCt+73UQ= Received: (qmail 90915 invoked by alias); 16 Jan 2018 03:04:26 -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 90895 invoked by uid 89); 16 Jan 2018 03:04:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=AWL, 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.2 spammy=H*RU:209.85.160.65, Hx-spam-relays-external:209.85.160.65 X-HELO: mail-pl0-f65.google.com Received: from mail-pl0-f65.google.com (HELO mail-pl0-f65.google.com) (209.85.160.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 16 Jan 2018 03:04:24 +0000 Received: by mail-pl0-f65.google.com with SMTP id f4so3680780plr.10 for ; Mon, 15 Jan 2018 19:04:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=0D+gebx6GXLtubQzy7P1YkO0aclxaI1tKzdad3TnEjY=; b=eVWsWi+zRmK+AVmf1hCZkI8retyytdyojkNHtbrbOfLNpr7SYY3R/JxzDysmwtSU6H IkO9VMrb6pK0NUDusp55qDpqfOg5u3k1XHpUDAiMDx0EUeIRT3LTuP4hMaef0EFDWfT/ /vMR5f8Oj/bj6FJgPDonT3u6+UwwBeHcNV8gAKBK9rVhvkLGG5Zxtp0z5OrURbO8gS9k TTNyoQhbEZdsGeQSXzE+Pg19T7ZVAtAaJtcNugHEMasKv4lq5xLrs2TD+5kFH1xQE1CO K74QDsyusB4yXj6rsu3rFOgfKQrcwoYE8clVekTsg9VjTf7ukDSFR6FU0UGfO5kcdJDw p5YA== X-Gm-Message-State: AKGB3mI3yO7bUC2lelJDnkgdLMVeUUIuPy6I0v+v591/xuh/W4XMBrq7 JFzLndDaKds3pmw7sYoABJUmvcPC7mE= X-Google-Smtp-Source: ACJfBouGXaWNvVgpqSHn1j9R3V9wfNTJIPYw9Djl3rtSH4zmLXgFcwk+y77wQZ0dBNlgbjl+NtinFw== X-Received: by 10.84.128.197 with SMTP id a63mr36954204pla.421.1516071862581; Mon, 15 Jan 2018 19:04:22 -0800 (PST) Received: from rohan.internal.sifive.com ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id 14sm948440pga.12.2018.01.15.19.04.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Jan 2018 19:04:21 -0800 (PST) From: Jim Wilson To: gcc-patches@gcc.gnu.org Cc: Jim Wilson Subject: [PATCH] RISC-V: Increase mult/div cost if not implemented in hardware. Date: Mon, 15 Jan 2018 19:04:18 -0800 Message-Id: <20180116030418.4704-1-jimw@sifive.com> This increases the cost of multiply and divide when not present. This makes it more likely that a multiply by constant gets replaced by a sequence of shift and adds which is faster than a call to a libgcc routine. The divide cost change doesn't do anything useful at present, but is added for consistency. This was tested with a make check-gcc. There were no regressions. Committed. Jim 2018-01-15 Andrew Waterman gcc/ * config/riscv/riscv.c (riscv_rtx_costs) : Increase cost if !TARGET_MUL. : Increase cost if !TARGET_DIV. --- gcc/config/riscv/riscv.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gcc/config/riscv/riscv.c b/gcc/config/riscv/riscv.c index d260c0ebae1..19a01e0825a 100644 --- a/gcc/config/riscv/riscv.c +++ b/gcc/config/riscv/riscv.c @@ -1615,6 +1615,9 @@ riscv_rtx_costs (rtx x, machine_mode mode, int outer_code, int opno ATTRIBUTE_UN case MULT: if (float_mode_p) *total = tune_info->fp_mul[mode == DFmode]; + else if (!TARGET_MUL) + /* Estimate the cost of a library call. */ + *total = COSTS_N_INSNS (speed ? 32 : 6); else if (GET_MODE_SIZE (mode) > UNITS_PER_WORD) *total = 3 * tune_info->int_mul[0] + COSTS_N_INSNS (2); else if (!speed) @@ -1635,7 +1638,10 @@ riscv_rtx_costs (rtx x, machine_mode mode, int outer_code, int opno ATTRIBUTE_UN case UDIV: case UMOD: - if (speed) + if (!TARGET_DIV) + /* Estimate the cost of a library call. */ + *total = COSTS_N_INSNS (speed ? 32 : 6); + else if (speed) *total = tune_info->int_div[mode == DImode]; else *total = COSTS_N_INSNS (1);