From patchwork Sat Jan 6 14:19:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 123631 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp615678qgn; Sat, 6 Jan 2018 06:19:49 -0800 (PST) X-Google-Smtp-Source: ACJfBouOhDie0hoYBKT1IlwDTvRktPTioRONZ17c8Gla5QgY+eXQhVNtkndWOE3DG/gh4E3dPul4 X-Received: by 10.159.244.149 with SMTP id y21mr6554374plr.358.1515248389535; Sat, 06 Jan 2018 06:19:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515248389; cv=none; d=google.com; s=arc-20160816; b=QkyJKBSJCnVR733q9EzQBcgn7ETcYp+Gqb74JWqbb2NSx0oJw71fFeX8yIslBcThm0 CN/cJYTJ2LxMxWcjjKyQWAQ1XvlAC6xc6zo04/0eRthAcwJIgmHSlwNe+4p39vHDws7+ 7mhp787W9fF9y+N1gkyuWPD9mxziCBVSWWyyOVWHQRRmtWkZCVG9HHQSqnWKYG6D0Yj6 fK6ZWPmHCkt2bVBysxE9WTulk93PfGnONHBlhHljTNFvZzZLW2bkGeZ0YFczwtzcbMuk WiqlKDlnbiBofcPJKaI4KXj2UUlrGZDK6DEw2ndXG6GCY2+A5dyF+VUkGKwsyjORB3VL X5ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:date:subject:mail-followup-to:to :from:delivered-to:sender:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=ODulJmADJtqBI+bDoDj9eWdSHhcOw6e9hwtf6CdsEus=; b=TEZidO5mKFnBFUhqJfB4RJB0t7ZuenpWu5fcgYgNlq/MVKwNnd7zhQuOn5Q2OV0ZVA pq7K35Ygjk//TPQYP4J63aO/gcvxI01ksad+B340JlLHPL4IswJ997fmT1GTzx1+QXJL SMAfPa2E/c68W6x0WktpO1nYxkK6mK2IsMMtEAnQFCKCpaAoMlUYHxXrHnWN6IkhIPJI qXzOAVGf/bwX9Oqc68yhiSf8xTxTausolzPJtJhGTZky7ZPAPOTM3dD79hf4mez2TcDq N9aP7miAz0m3hlHbg919zfZgPaaGTfdvHBgZ5R/J43yIHBbB7nljbr82jDfGjJdCfB7h TgUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=idsU48pQ; spf=pass (google.com: domain of gcc-patches-return-470297-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-470297-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id v20si5740544plo.820.2018.01.06.06.19.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 06 Jan 2018 06:19:49 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-470297-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=idsU48pQ; spf=pass (google.com: domain of gcc-patches-return-470297-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-470297-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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; q=dns; s= default; b=SwrTfX7HGl3AL5Y+K59n8Cr1uj9aoECQU57szuufLByHNKbUPcvap iDp+seYeVEVoTORTau5LKOSWdBwQld3UnNonoQ96kwvFN2EUHU26/fQ8l7ns4v6w MhsWC8tWw+SyOdcnZ7lAu4SJHjWkPps2bUs+h5LO2ZG0aIR1hdeZFQ= 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; s= default; bh=cHGSMmdHF1jI8zKalL+VH4SYpF8=; b=idsU48pQ5Aniv2zvBUz3 kuOsCGVMH8J4dvNn2gduuRHsp6SQ0hAmJDYHsK0YIgcGHhLy4fHLHugdH1CYAUSK UOuaWY0wZgs6nAfKt5fomXgODDcb2Db0XvbiK3YaaQ1CHKJpqmfSaWGzJYAPWqpZ T8oZiZ56iXhTgVSW/Gg7HxA= Received: (qmail 102390 invoked by alias); 6 Jan 2018 14:19:38 -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 102377 invoked by uid 89); 6 Jan 2018 14:19:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-12.1 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= X-HELO: mail-wr0-f179.google.com Received: from mail-wr0-f179.google.com (HELO mail-wr0-f179.google.com) (209.85.128.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 06 Jan 2018 14:19:36 +0000 Received: by mail-wr0-f179.google.com with SMTP id f8so6677851wre.4 for ; Sat, 06 Jan 2018 06:19:35 -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:mail-followup-to:subject:date:message-id :user-agent:mime-version; bh=ODulJmADJtqBI+bDoDj9eWdSHhcOw6e9hwtf6CdsEus=; b=VDcAJXWYQz0DaUugcxTPgbPJlZ7MzfhGYiRy8Ti3wm6yaqw6usDMzEITznG7NvFqnl eZz111mY8Ew300Oqwm8c9PDYL7/Yk+t3WmRcavaa60rd2dnjFiwIjmQhOnY5O8sNvEie yb86WyB5OLK7laKiFsH6uV/hjyrdTLzTbb793idVYVxFBZgKWAx/fpEFav+m32JTvcas ajcyr/+jWV7Unm1Qdu2hFiOc80rlkX0QI9w4c2LZ4CK1sqI7nU0JX/Zyi9niMXTLe+og GKwmfNiK1uBX6u4dCTWQMsRpzFoDRONUh4ipmp8jHbeoN40ovC/gHfLG8hcSc0c3R1FU pa6g== X-Gm-Message-State: AKGB3mKrVlW1WG6j4um25yR5cOokZRVWPeZ/Y0AxEcI2oqLKO2DYdM0G L+d4emh6twa95uYDyrMWDm5/jFVNlco= X-Received: by 10.223.136.131 with SMTP id f3mr4186256wrf.246.1515248373831; Sat, 06 Jan 2018 06:19:33 -0800 (PST) Received: from localhost ([95.144.14.233]) by smtp.gmail.com with ESMTPSA id f125sm6055805wme.45.2018.01.06.06.19.32 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 06 Jan 2018 06:19:32 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: Restrict vector use of extract_bit_field_as_subreg (PR 83699) Date: Sat, 06 Jan 2018 14:19:31 +0000 Message-ID: <87h8rzgjd8.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 The code in r256209 tried using subregs for two cases: to extract a lowpart element of a vector, or to extract a subvector from a wider vector. An earlier version of the SVE port used both variants, but these days SVE provides vec_extract* for all cases and so only really needs the subvector extract, e.g. for extracting one vector from an LD[234] result. 64-bit SPARC is unusual in that REGMODE_NATURAL_SIZE for vectors is smaller than for GPRs. It's therefore valid to form a subreg reference to both halves of a V2SI but not to both halves of a DI. This is where the problem in PR83699 comes from: we extract the highpart SI from a V2SI and want to move the result into a GPR. This causes LRA to cycle, because it keeps emitting reload sequences of the form: (set (reg:SI tmp) (subreg:SI (reg:V2SI foo) 0)) (set (reg:SI reg) (reg:SI tmp)) but then assigning a GPR to tmp, thus creating the same reload problem as before. However, even with that fixed, the sequence is worse than it was before r256209. I don't think this means that using subregs is a bad idea in principle, just that it needs a different condition. (E.g. if SPARC supported V2SF, or if it was prepared to do the SImode operation on FPRs, the patch would have been an improvement, because we'd avoid doing the extraction via memory.) But since there's no longer a motivating example for the single-element case, I think the best approach is just to drop it. For the remaining subvector case, we *could* continue to use the GET_MODE_INNER check as well, but I don't think it's necessary, since what really matters is whether the register reference can be formed. Tested so far on aarch64-linux-gnu, and by spot-checking a sparch64-linux-gnu cross. OK To install? Richard 2018-01-06 Richard Sandiford gcc/ PR rtl-optimization/83699 * expmed.c (extract_bit_field_1): Restrict the vector usage of extract_bit_field_as_subreg to cases in which the extracted value is also a vector. Index: gcc/expmed.c =================================================================== --- gcc/expmed.c 2018-01-06 10:55:43.333837784 +0000 +++ gcc/expmed.c 2018-01-06 14:15:01.179591726 +0000 @@ -1738,16 +1738,10 @@ extract_bit_field_1 (rtx str_rtx, poly_u return target; } } - /* Using subregs is useful if we're extracting the least-significant - vector element, or if we're extracting one register vector from - a multi-register vector. extract_bit_field_as_subreg checks - for valid bitsize and bitnum, so we don't need to do that here. - - The mode check makes sure that we're extracting either - a single element or a subvector with the same element type. - If the modes aren't such a natural fit, fall through and - bitcast to integers first. */ - if (GET_MODE_INNER (mode) == innermode) + /* Using subregs is useful if we're extracting one register vector + from a multi-register vector. extract_bit_field_as_subreg checks + for valid bitsize and bitnum, so we don't need to do that here. */ + if (VECTOR_MODE_P (mode)) { rtx sub = extract_bit_field_as_subreg (mode, op0, bitsize, bitnum); if (sub)