From patchwork Tue Nov 6 09:38:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 993559 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-489130-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="VTrbqGfh"; 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 42q4HL0cnsz9sDT for ; Tue, 6 Nov 2018 20:38:35 +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-type :content-transfer-encoding; q=dns; s=default; b=GHmGeubGP93wBeCW SKsXJZijJWwgQQB1kAtnJjmykDq+vb5D532SaE9NkvqEtr6IAwLd8ZGOMS+k/EnU UzZObr6Iu1WLI5HcgVQ4ZG9XkQ9C7yjnJOrgMHgTa6oWHAg0qYdDvzcc6fQwwmPr lhy4+mRF/YsQevKZjxVcq7o6Vk4= 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-type :content-transfer-encoding; s=default; bh=Yb3e3GHW5i8iGRWT+Iz63w zPvIw=; b=VTrbqGfhMKu79O5iGtRRdrLHOWJVgfBMk5KCQPuvGDO91qV3ArsFHi JItPRCglG6o2071Bp1JJ56sXX8zfLHipB57SkWRjzNdcVz1GxWbfvqWPiMnGRfSD EZHVitS/6MJ0DclxTUsEvUg+52kdXB53RkXcqE3s3n4ttH6WfGdm4= Received: (qmail 67198 invoked by alias); 6 Nov 2018 09:38:27 -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 67093 invoked by uid 89); 6 Nov 2018 09:38:26 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=hay, pero, Latin, latin X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 06 Nov 2018 09:38:24 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5D6283082A36 for ; Tue, 6 Nov 2018 09:38:23 +0000 (UTC) Received: from free.home (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 17CA65C880; Tue, 6 Nov 2018 09:38:22 +0000 (UTC) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTP id wA69cCNL347114; Tue, 6 Nov 2018 07:38:12 -0200 From: Alexandre Oliva To: Vladimir Makarov Cc: gcc-patches@gcc.gnu.org Subject: [PR87874] avoid const-wide-int subreg in LRA Date: Tue, 06 Nov 2018 07:38:12 -0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Just like CONST_INT, CONST_WIDE_INT is VOIDmode, so LRA might be tempted to build a SUBREG to "convert" it to the wanted mode. That's no use. Test for CONST_SCALAR_INT_P instead of CONST_INT_P so that we skip the subreg creation for both. Regstrapped on x86_64- and i686-linux-gnu. Ok to install? for gcc/ChangeLog PR rtl-optimization/87874 * lra.c (lra_substitute_pseudo): Do not create a subreg for const wide ints. for gcc/testsuite/ChangeLog PR rtl-optimization/87874 * gcc.dg/pr87874.c: New. --- gcc/lra.c | 2 +- gcc/testsuite/gcc.dg/pr87874.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/pr87874.c diff --git a/gcc/lra.c b/gcc/lra.c index aa768fb2a231..5d58d90f3a6b 100644 --- a/gcc/lra.c +++ b/gcc/lra.c @@ -1961,7 +1961,7 @@ lra_substitute_pseudo (rtx *loc, int old_regno, rtx new_reg, bool subreg_p, machine_mode inner_mode = GET_MODE (new_reg); if (mode != inner_mode - && ! (CONST_INT_P (new_reg) && SCALAR_INT_MODE_P (mode))) + && ! (CONST_SCALAR_INT_P (new_reg) && SCALAR_INT_MODE_P (mode))) { poly_uint64 offset = 0; if (partial_subreg_p (mode, inner_mode) diff --git a/gcc/testsuite/gcc.dg/pr87874.c b/gcc/testsuite/gcc.dg/pr87874.c new file mode 100644 index 000000000000..3ab5dcf68ffb --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr87874.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-options "-g -O1 -fgcse -fno-dce -fno-tree-ccp -fno-tree-coalesce-vars -fno-tree-copy-prop -fno-tree-dce -fno-tree-dominator-opts -fno-tree-fre -fno-tree-loop-optimize -fno-tree-sink" } */ + +int *vk; +int m2; +#if __SIZEOF_INT128__ +__int128 nb; + +void +em (int u5, int fo, int s7) +{ + for (;;) + { + long int es; + + es = !!u5 ? (!!fo && !!m2) : fo; + if (es == 0) + if (nb == *vk) + { + const unsigned long int uint64_max = 18446744073709551615ul; + __int128 ks = uint64_max / 2 + 1; + + while (s7 < 1) + while (nb < 2) + { + for (ks = 0; ks < 3; ++ks) + { + } + + ++nb; + } + } + } +} +#endif