From patchwork Tue Oct 31 18:28:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 832686 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-465637-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="MT+SuncO"; 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 3yRKbj3HB0z9sQl for ; Wed, 1 Nov 2017 05:28:15 +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:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=kSlda0E4I1f5BbT+ OKJNZ9hyFxOI6jyHjhqcLsXJHvUpmJdzn0z20cFAYsQ6q27lTBMuyDAENUkKMBGx qpuC0+XgUZeYCHKZSwGQp0rJ8LrlJHgObBBYSLCkG2P7zcep2PdQvo0hxMY+LyPM v9ExxVtyrKGsNCx3s/Lb+mTftfc= 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 :content-transfer-encoding; s=default; bh=lJ0XvbeNbrGcRHVU1Sg3p+ dwGws=; b=MT+SuncOV7q14BeiW0Pfm3ZyegEH2oL/F1T8U7ibqDHO5fp/e6kOUp +J3DjX90fmuNq1sFP5TeJMtZzcWxwSBe/OpjgzMldQqDa8MqI6zTSHG5pV2ynhW3 V19FiFGJVTnz0iL8JV+MECYQdNPmYlVvg3N0IAfNwFnTncX1MFwOM= Received: (qmail 6555 invoked by alias); 31 Oct 2017 18:28:06 -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 6541 invoked by uid 89); 31 Oct 2017 18:28:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Fortune, reloading X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 31 Oct 2017 18:28:04 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 56EF9818D7 for ; Tue, 31 Oct 2017 19:28:01 +0100 (CET) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TPns2U4yMbPd for ; Tue, 31 Oct 2017 19:28:01 +0100 (CET) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 2B02A8152A for ; Tue, 31 Oct 2017 19:28:01 +0100 (CET) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: Fix PR rtl-optimization/81803 Date: Tue, 31 Oct 2017 19:28 +0100 Message-ID: <3922835.sLAUAVvKQN@polaris> User-Agent: KMail/4.14.10 (Linux/3.16.7-53-desktop; KDE/4.14.9; x86_64; ; ) MIME-Version: 1.0 This is a regression present on the mainline and 7 branch for little-endian 64-bit MIPS platforms under the form of incorrect spill/reload pairs generated by the LRA pass, i.e. for which the spill instruction is a narrower access than the reload instruction. That's incorrect for accesses no wider than a word on WORD_REGISTER_OPERATIONS target because all the bits up to the word size need to be preserved. The attached patch fixes the problem by mimicing in curr_insn_transform what push_reload does for SUBREGs no wider than a word for WORD_REGISTER_OPERATIONS targets, i.e. reloading the whole register and not just the subreg. Tested on SPARC64/Linux and ARM/EABI (both WORD_REGISTER_OPERATIONS targets). Unfortunately I don't have access to MIPS hardware anymore and the PR doesn't contain any executable testcase. Applied on the mainline only for now. 2017-10-31 Matthew Fortune Eric Botcazou PR rtl-optimization/81803 * lra-constraints.c (curr_insn_transform): Also reload the whole register for a strict subreg no wider than a word if this is for a WORD_REGISTER_OPERATIONS target. Index: lra-constraints.c =================================================================== --- lra-constraints.c (revision 254193) +++ lra-constraints.c (working copy) @@ -4207,8 +4207,9 @@ curr_insn_transform (bool check_only_p) reg = SUBREG_REG (*loc); byte = SUBREG_BYTE (*loc); if (REG_P (reg) - /* Strict_low_part requires reload the register not - the sub-register. */ + /* Strict_low_part requires reloading the register and not + just the subreg. Likewise for a strict subreg no wider + than a word for WORD_REGISTER_OPERATIONS targets. */ && (curr_static_id->operand[i].strict_low || (!paradoxical_subreg_p (mode, GET_MODE (reg)) && (hard_regno @@ -4219,7 +4220,11 @@ curr_insn_transform (bool check_only_p) && (goal_alt[i] == NO_REGS || (simplify_subreg_regno (ira_class_hard_regs[goal_alt[i]][0], - GET_MODE (reg), byte, mode) >= 0))))) + GET_MODE (reg), byte, mode) >= 0))) + || (GET_MODE_PRECISION (mode) + < GET_MODE_PRECISION (GET_MODE (reg)) + && GET_MODE_SIZE (GET_MODE (reg)) <= UNITS_PER_WORD + && WORD_REGISTER_OPERATIONS))) { /* An OP_INOUT is required when reloading a subreg of a mode wider than a word to ensure that data beyond the