From patchwork Wed Jan 31 08:23:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 85066 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 3DBA8385843A for ; Wed, 31 Jan 2024 08:24:04 +0000 (GMT) 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 D911B3858C2D for ; Wed, 31 Jan 2024 08:23:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D911B3858C2D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D911B3858C2D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706689404; cv=none; b=R821mmzbgykolfq0Jjz745lXnsJTa9upBeCwTjDDXbdeQp3bXZdGeKk0EfeLfI2JXa+zdrwFawbDlmhfeJ+6jH9hpOXi+O45Uaa3nBa3ostZvLfRepjgs1KsXchfyYdLePgwKs5wPsC38q21T298fDdsXibQS6wKRa+iVdn8k4U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706689404; c=relaxed/simple; bh=zP/aCRQepalgHrkqwOdxQ0lu2deQRIFlIDpeZG4DkzY=; h=Date:From:To:Subject:Message-ID:MIME-Version; b=rv+fpAmqIzp4m/QhVZ21y6Pe8BXPfrPXgB/UkrkiUV++A7B7gf3K2R2sPJY0d9xc9u8DrnwKUyiNTa6HOOb68FYQMiWveTwzmGIHdYlFo292oJC+hifm6lYefVRdAGwDZQwKk7vPDOJOAPWYFQvEY8c6iU7EZB+6DuYzjatAFRc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-658-l72YxxUnPp6aVOIHFdh2qg-1; Wed, 31 Jan 2024 03:23:18 -0500 X-MC-Unique: l72YxxUnPp6aVOIHFdh2qg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9EEBF101A526; Wed, 31 Jan 2024 08:23:18 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.70]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6332C492BC6; Wed, 31 Jan 2024 08:23:18 +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 40V8NFA8266947 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 09:23:16 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 40V8NFXp266946; Wed, 31 Jan 2024 09:23:15 +0100 Date: Wed, 31 Jan 2024 09:23:14 +0100 From: Jakub Jelinek To: Uros Bizjak Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] i386: Clear REG_UNUSED and REG_DEAD notes from the IL at the end of vzeroupper pass [PR113059] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-22.8 required=5.0 tests=BAYES_00, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Hi! The move of the vzeroupper pass from after reload pass to after postreload_cse helped only partially, CSE-like passes can still invalidate those notes (especially REG_UNUSED) if they use some earlier register holding some value later on in the IL. So, either we could try to move it one pass further after gcse2 and hope no later pass invalidates the notes, or the following patch attempts to restore the REG_DEAD/REG_UNUSED state from GCC 13 and earlier, where the LRA or reload passes remove all REG_DEAD/REG_UNUSED notes and the notes reappear only at the start of dse2 pass when it calls df_note_add_problem (); df_analyze (); So, effectively NEXT_PASS (pass_postreload_cse); NEXT_PASS (pass_gcse2); NEXT_PASS (pass_split_after_reload); NEXT_PASS (pass_ree); NEXT_PASS (pass_compare_elim_after_reload); NEXT_PASS (pass_thread_prologue_and_epilogue); passes operate without those notes in the IL. While in GCC 14 mode switching computes the notes problem at the start of vzeroupper, the patch below removes them at the end of the pass again, so that the above passes continue to operate without them. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2024-01-31 Jakub Jelinek PR target/113059 * config/i386/i386-features.cc (rest_of_handle_insert_vzeroupper): Remove REG_DEAD/REG_UNUSED notes at the end of the pass before df_analyze call. Jakub --- gcc/config/i386/i386-features.cc.jj 2024-01-08 12:15:13.611477047 +0100 +++ gcc/config/i386/i386-features.cc 2024-01-30 12:36:27.834515803 +0100 @@ -2664,6 +2664,32 @@ rest_of_handle_insert_vzeroupper (void) /* Call optimize_mode_switching. */ g->get_passes ()->execute_pass_mode_switching (); + /* LRA removes all REG_DEAD/REG_UNUSED notes and normally they + reappear in the IL only at the start of pass_rtl_dse2, which does + df_note_add_problem (); df_analyze (); + The vzeroupper is scheduled after postreload_cse pass and mode + switching computes the notes as well, the problem is that e.g. + pass_gcse2 doesn't maintain the notes, see PR113059 and + PR112760. Remove the notes now to restore status quo ante + until we figure out how to maintain the notes or what else + to do. */ + basic_block bb; + rtx_insn *insn; + FOR_EACH_BB_FN (bb, cfun) + FOR_BB_INSNS (bb, insn) + if (NONDEBUG_INSN_P (insn)) + { + rtx *pnote = ®_NOTES (insn); + while (*pnote != 0) + { + if (REG_NOTE_KIND (*pnote) == REG_DEAD + || REG_NOTE_KIND (*pnote) == REG_UNUSED) + *pnote = XEXP (*pnote, 1); + else + pnote = &XEXP (*pnote, 1); + } + } + df_analyze (); return 0; }