From patchwork Tue Mar 28 08:10:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 75889 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2048637vqo; Tue, 28 Mar 2023 01:11:52 -0700 (PDT) X-Google-Smtp-Source: AKy350adGuyEpqmSLElPKKNkz9Vka7wmXiaBVYFniB3YdP6fV+6yRQyADpZQUecR1jIByUgY4WfW X-Received: by 2002:a17:907:c25:b0:895:58be:957 with SMTP id ga37-20020a1709070c2500b0089558be0957mr19310614ejc.2.1679991112786; Tue, 28 Mar 2023 01:11:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679991112; cv=none; d=google.com; s=arc-20160816; b=oY54lQK9afMPz4blxbty0D/v+MGE/R7OIeEcnd4Fb8NtofvaFhGJtAMVylFuJurY1I UUdYjBZdmBh6u/q9Arrrt7StDkyRJM8f+QNtfDitFrigRO4xwOQEpkx/qEeFpaUgE5j/ ZeGDCDOdhJD7CYwgWDo+pR9eiI3ooIvLIpaLLgh9MGFZlBpZMsNP1CzS+PYnzwIvRGxs gH2YfHHRm7hJ3NwIxFTdD56nC/3YF1p7iOodDSk/nInkcuVp61r76AoBTRBT5MtQNTZU zGZw1UaGckCqPrpAEKIdHv5E+az0m59siUO29MyWfLGeYNYoVyloSk7hBMKIx6vV1q2c USNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=YP45fRDeloNKUYMoNNvFyyHct2eMk9iNBhV2mnLDP9k=; b=c0c3eCCiilp6j//Zdyx21KNC0uk+iOuL7odcRs75UzCK7M2Mw3DvLFVZgSHRoOJuPl nZUMdDSUDQc970o70uk9D3O/2xQE/1ZIuu/j7ZZGNTqNwnrnWV5+DmxLdMTs6T56RCBL AdZqus51lAmYNeCLIKc1iHgh63a3UDGM7jQIjv/pzmknAhv5ur1zC6lk4InrsMyDy1OV EiVDo0dIsjeyqTWJ3kjbDD2Wmgh1SxR5GqEulgNdbCdgYCcM7nWx0YhAK2vl5GZRnWnk 8YS5EWnbRDEfWI6VZb8btYCC5BAXShHNi2/df9Uw0Z7DM9Av4dlueffGk1fGfJVur3Uu /JYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=oioBkpz3; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id fy8-20020a1709069f0800b009335b145df8si7636731ejc.363.2023.03.28.01.11.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Mar 2023 01:11:52 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=oioBkpz3; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 532083858CDA for ; Tue, 28 Mar 2023 08:11:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 532083858CDA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679991110; bh=YP45fRDeloNKUYMoNNvFyyHct2eMk9iNBhV2mnLDP9k=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=oioBkpz3aoARGx1kyO16rEnGLEy5Ek9YEbTHzL0a+JXL7VqlHMENLiGt9NiiQ/gET fYXJdFPOKArISiEqy3YV5n408mB0BksvCXxCWrVuP1sM3Bz8HlGhAyzuvahLVvlBTx uJepsGn0Z/1mNM1xOAfUoUP3Lh8bDlnKYyziHnsU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 812063858D39 for ; Tue, 28 Mar 2023 08:11:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 812063858D39 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-434-T_oVj9ExNmWNc8vj_DaNbA-1; Tue, 28 Mar 2023 04:10:58 -0400 X-MC-Unique: T_oVj9ExNmWNc8vj_DaNbA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7C3BB887402; Tue, 28 Mar 2023 08:10:58 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3DF3B140EBF4; Tue, 28 Mar 2023 08:10:58 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 32S8AoZF1442022 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 28 Mar 2023 10:10:51 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 32S8AnYK1442021; Tue, 28 Mar 2023 10:10:49 +0200 Date: Tue, 28 Mar 2023 10:10:49 +0200 To: Uros Bizjak , hjl.tools@gmail.com Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] i386: Require just 32-bit alignment for SLOT_FLOATxFDI_387 -m32 -mpreferred-stack-boundary=2 DImode temporaries [PR109276] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761598361246772647?= X-GMAIL-MSGID: =?utf-8?q?1761598361246772647?= Hi! The following testcase ICEs since r11-2259 because assign_386_stack_local -> assign_stack_local -> ix86_local_alignment now uses 64-bit alignment for DImode temporaries rather than 32-bit as before. Most of the spots in the backend which ask for DImode temporaries are during expansion and those apparently are handled fine with -m32 -mpreferred-stack-boundary=2, we dynamically realign the stack in that case (most of the spots actually don't need that alignment but at least one does), then 2 spots are in STV which I assume also work correctly. But during splitting we can create a DImode slot which doesn't need to be 64-bit alignment (it is nicer for performance though), when we apparently aren't able to detect it for dynamic stack realignment purposes. The following patch just makes the slot 32-bit aligned in that rare case. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2023-03-28 Jakub Jelinek PR target/109276 * config/i386/i386.cc (assign_386_stack_local): For DImode with SLOT_FLOATxFDI_387 and -m32 -mpreferred-stack-boundary=2 pass align 32 rather than 0 to assign_stack_local. * gcc.target/i386/pr109276.c: New test. Jakub --- gcc/config/i386/i386.cc.jj 2023-03-23 10:00:58.415099003 +0100 +++ gcc/config/i386/i386.cc 2023-03-27 17:36:37.405390440 +0200 @@ -16682,10 +16682,18 @@ assign_386_stack_local (machine_mode mod if (s->mode == mode && s->n == n) return validize_mem (copy_rtx (s->rtl)); + int align = 0; + /* For DImode with SLOT_FLOATxFDI_387 use 32-bit + alignment with -m32 -mpreferred-stack-boundary=2. */ + if (mode == DImode + && !TARGET_64BIT + && n == SLOT_FLOATxFDI_387 + && ix86_preferred_stack_boundary < GET_MODE_ALIGNMENT (DImode)) + align = 32; s = ggc_alloc (); s->n = n; s->mode = mode; - s->rtl = assign_stack_local (mode, GET_MODE_SIZE (mode), 0); + s->rtl = assign_stack_local (mode, GET_MODE_SIZE (mode), align); s->next = ix86_stack_locals; ix86_stack_locals = s; --- gcc/testsuite/gcc.target/i386/pr109276.c.jj 2023-03-27 17:43:59.977007379 +0200 +++ gcc/testsuite/gcc.target/i386/pr109276.c 2023-03-27 17:44:52.516249622 +0200 @@ -0,0 +1,13 @@ +/* PR target/109276 */ +/* { dg-do compile } */ +/* { dg-options "-march=x86-64" } */ +/* { dg-additional-options "-mpreferred-stack-boundary=2" { target ia32 } } */ + +long long a; +long double b; + +void +foo (void) +{ + b += a; +}