From patchwork Wed Sep 11 19:09:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 1161246 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-508901-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="eyYlJLbx"; 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 46TBKk4ttXz9s7T for ; Thu, 12 Sep 2019 05:09:45 +1000 (AEST) 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=v5AV4tGPptn8MqaTp2PN0jR9IIfEz oARNFXtlL+/FGAd5PPJwbUp4ejUWPIZMrfofpF8n45rkA0oKtVq5b9RJ52Bl4rWy RqOTB5gpNjlN3VgjXyNBReUk75V3jieNapBf0m5ecjVKMqfr1e18uvW2iFNV090K Kw1JIwl7p8pP4A= 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=/iOYn4qE6eSc9lf4UHXk9Vpixtc=; b=eyY lJLbxHgoq1XtQ2NvLNoMGLYN/umVMj4jF6fLMJj+eg71a9L766iiMxdKTJ70bVlp po+HfF3ZS5tuYDHz6HMmNZbGtHdNqFYGa7fcD4cAHWMS71ddw2iB1mOPJd0GR5M3 0SYSyiSdRRWOCjaUj5oG4f5uiSLduUlPF/YR/LYE= Received: (qmail 95711 invoked by alias); 11 Sep 2019 19:09:36 -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 95673 invoked by uid 89); 11 Sep 2019 19:09:36 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-9.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.110.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 11 Sep 2019 19:09:33 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6EFFB28 for ; Wed, 11 Sep 2019 12:09:32 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.99.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 174B53F59C for ; Wed, 11 Sep 2019 12:09:31 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [12/32] Remove global call sets: cselib.c References: Date: Wed, 11 Sep 2019 20:09:30 +0100 In-Reply-To: (Richard Sandiford's message of "Wed, 11 Sep 2019 20:02:26 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes cselib_invalidate_regno is a no-op if REG_VALUES (i) is null, so we can check that first. Then, if we know what mode the register currently has, we can check whether it's clobbered in that mode. Using GET_MODE (values->elt->val_rtx) to get the mode of the last set is taken from cselib_reg_set_mode. 2019-09-11 Richard Sandiford gcc/ * cselib.c (cselib_process_insn): If we know what mode a register was set in, check whether it is clobbered in that mode by a call. Only fall back to reg_raw_mode if that fails. Index: gcc/cselib.c =================================================================== --- gcc/cselib.c 2019-09-11 19:47:32.894202944 +0100 +++ gcc/cselib.c 2019-09-11 19:48:04.229982128 +0100 @@ -2768,11 +2768,23 @@ cselib_process_insn (rtx_insn *insn) { function_abi abi = call_insn_abi (insn); for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) - if (call_used_or_fixed_reg_p (i) - || (REG_VALUES (i) && REG_VALUES (i)->elt - && (targetm.hard_regno_call_part_clobbered - (abi.id (), i, GET_MODE (REG_VALUES (i)->elt->val_rtx))))) - cselib_invalidate_regno (i, reg_raw_mode[i]); + if (elt_list *values = REG_VALUES (i)) + { + /* If we know what mode the value was set in, check whether + it is still available after the call in that mode. If we + don't know the mode, we have to check for the worst-case + scenario instead. */ + if (values->elt) + { + if (abi.clobbers_reg_p (GET_MODE (values->elt->val_rtx), i)) + cselib_invalidate_regno (i, GET_MODE (values->elt->val_rtx)); + } + else + { + if (abi.clobbers_at_least_part_of_reg_p (i)) + cselib_invalidate_regno (i, reg_raw_mode[i]); + } + } /* Since it is not clear how cselib is going to be used, be conservative here and treat looping pure or const functions