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: 66987 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0DB5B385840E for ; Tue, 28 Mar 2023 08:11:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0DB5B385840E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679991095; bh=YP45fRDeloNKUYMoNNvFyyHct2eMk9iNBhV2mnLDP9k=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=f3zBw03mT60rGhre5+WOhr/ub7DgqEnUCVFANS+UuxOkAy4JCOpneqoN2NA+ki9oF 3SgIg8a+dCuAi3MxlOZ6WrXRI80NDV8HdRaqqrsLeZAPSn66RAebF8hbps09gU6+iB bfwQzPdtGw57nlVztyaX+XJcVHAazehYzCvyM7Uo= 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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; +}