From patchwork Fri Sep 10 04:52:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liuhongt X-Patchwork-Id: 1526365 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=QZbE+j9O; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4H5NmX6LNsz9sXV for ; Fri, 10 Sep 2021 14:53:15 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6BA2D384A8A5 for ; Fri, 10 Sep 2021 04:53:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6BA2D384A8A5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1631249591; bh=8SC6GOJhFPTsJkLYlJIceqxOBJnNopLt2JxHJePWl9k=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=QZbE+j9O4IT1ZPh3CsPkg2eNvAL+PkEso3j9nj9sBnwn+kGUxo6Cj3x6D/BB0Q+4Z Ib5lr4u5R+rjwC9xcGpcnIheRtxYJ2jNSSkH/RjNh055MsHvI7AfCl/DWG1pdX6xEQ 5cbLUdWTrNcnebJ/FoUlyjpyt7/M1PML7mDo0yl8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by sourceware.org (Postfix) with ESMTPS id 525F23858C39 for ; Fri, 10 Sep 2021 04:52:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 525F23858C39 X-IronPort-AV: E=McAfee;i="6200,9189,10102"; a="201186734" X-IronPort-AV: E=Sophos;i="5.85,282,1624345200"; d="scan'208";a="201186734" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Sep 2021 21:52:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,282,1624345200"; d="scan'208";a="479995361" Received: from scymds01.sc.intel.com ([10.148.94.138]) by orsmga008.jf.intel.com with ESMTP; 09 Sep 2021 21:52:28 -0700 Received: from shliclel219.sh.intel.com (shliclel219.sh.intel.com [10.239.236.219]) by scymds01.sc.intel.com with ESMTP id 18A4qQqL004734; Thu, 9 Sep 2021 21:52:27 -0700 To: gcc-patches@gcc.gnu.org Subject: [PATCH] Disallow paradoxical subregs when outer mode is SCALAR_FLOAT_MODE_P. Date: Fri, 10 Sep 2021 12:52:26 +0800 Message-Id: <20210910045226.3752863-1-hongtao.liu@intel.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: liuhongt via Gcc-patches From: liuhongt Reply-To: liuhongt Cc: rdsandiford@googlemail.com Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi: In general_operand, paradoxical subregs w/ outermode SCALAR_FLOAT_MODE_P are not allowed unless lra_in_progress, so this patch add the restriction to validate_subreg as well. Bootstrapped and regtested on x86_64-linux-gnu{-m32,} Also the newly added tests are compiled with aarch64-linux-gnu-gcc w/o ICE. Ok for trunk? gcc/ChangeLog: PR middle-end/102254 PR middle-end/102154 * emit-rtl.c (validate_subreg): Disallow paradoxical subregs when omode is SCALAR_FLOAT_MODE_P. gcc/testsuite/ChangeLog: * gcc.target/i386/pr102254.c: New test. --- gcc/emit-rtl.c | 8 ++++++-- gcc/testsuite/gcc.target/i386/pr102254.c | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr102254.c diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index 77ea8948ee8..29fa29e1001 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -922,9 +922,13 @@ validate_subreg (machine_mode omode, machine_mode imode, poly_uint64 regsize = REGMODE_NATURAL_SIZE (imode); - /* Paradoxical subregs must have offset zero. */ + /* Paradoxical subregs must have offset zero and omode not + SCALAR_FLOAT_MODE_P. + i.e. things like (subreg:DF (reg:SF)) or (subreg:DF (reg:SI)) + are not allowed. */ if (maybe_gt (osize, isize)) - return known_eq (offset, 0U); + return known_eq (offset, 0U) + && (!SCALAR_FLOAT_MODE_P (omode) || lra_in_progress); /* This is a normal subreg. Verify that the offset is representable. */ diff --git a/gcc/testsuite/gcc.target/i386/pr102254.c b/gcc/testsuite/gcc.target/i386/pr102254.c new file mode 100644 index 00000000000..93d25c3d317 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr102254.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-Og" } */ + +#define MODFL __builtin_modfl +void +foo (void) +{ + int x; + *((double *) &x) = 0; +} + +void +foo1 (void) +{ + float x; + + *((double *) &x) = 0; +} + +void foo2() { + long iptrll; + MODFL(0.5l, (long double *)&iptrll); +}