From patchwork Wed Jan 11 04:20:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takayuki 'January June' Suwa X-Patchwork-Id: 1724457 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.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=W51Ko2yE; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NsDyS491vz23fj for ; Wed, 11 Jan 2023 15:21:18 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B44323858C5E for ; Wed, 11 Jan 2023 04:21:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B44323858C5E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1673410874; bh=Nyrf5xC2eoLuPy+xlXl9+tGCLltBrWBOfDszTgfdVh0=; h=Date:To:Subject:References:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=W51Ko2yEzb0HK6rVf3jpG61qEgBEaOjnjpx/rKKwzbQrVHv3bTwBi/gNPZfmZr82L go8QropzKYfIOZe6jxEfQNHZn2dk6TffJanP9CBbVPHZZWSW8TXr6fQHUmJ4/8zwBg rw4ZRK/KeY+U8NatOSVzC88Q52nQ2yZLVLPOnjBs= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from sonicconh5003-vm0.mail.kks.yahoo.co.jp (sonicconh5003-vm0.mail.kks.yahoo.co.jp [114.110.61.43]) by sourceware.org (Postfix) with ESMTPS id 0D4E33858D3C for ; Wed, 11 Jan 2023 04:20:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0D4E33858D3C X-YMail-OSG: F7elx_EVM1m8pUz6JodqjOWTSVJzgz17GlMexsh14qXsyycrqil7wRDO8VB9PH9 rdKG8uZ4By6xufV7BcswfeGZtRJGtaooB9Pwkn_yvNRQwEPbdoSAgzHQD_TS9uqFzDhkH0h.knuf EGZpz7sDq5ZsLu.Qx_XJjPXzeCJMdRiw3GIRsIzWC9QkBWQ5mnxdw2WN9LyXTz9g.pWGkoV_qYbf VlRUbcpK.bdbIY642HEfZyuuMGmOkUVYB2eEemy1TZ2jUVe2G.Bkv8YZlsjRMgND2M55jI83nxfC Vuh6CUJVPR_ddwZjwnfIFvvtD9ri8hAkPBXabUYo4dxETWH.vBj89b2Qx_RAw.qM80KPslRvWxpO BPTpEWSNbL0O0xNHtNIq_x5SGQdbuWEHHAQzLjlqvd1_D5I3ZtIo0SZO1LolXkFyzXteW2kWVP0l KHyqdy2ZWOB3f75pE_B7WKLcOfPM6ggbjUG.F8xpLJfecZYdi5e4nhzeL4qIgJG77dk4qcm1.RnT q.M40BS_HMn8mwPh0aH.8A8wodItMg4lWw7eOWwJGe663ULpJowqpufgcYf60XbxEWHpLcv_uzBY Q7Qzj23s6pidWZxllhRonq6oaB3zvrZXjkVlrlSJ.d5MbTZ1JJh579bcnj.6KpRb6q.lodAZWo6z Zu284MeK1S2KjYmQPP1mJTMvXIgi6GYzyZYHpOsLvrCIhuRFuQe_JToDnPctOIc27Av5yXhJuhrr LZ2FLUN4cEwVzltkU4qIZf54MWZxASDhX9xTmzkuXSTEy89m3PxyXb2YJGMPrOEcVqEDgpwJ._zd wv4amd3i0Of570RFsM5GuJq_wjNWllZqckzVzYhlAvl3Efkw29Cav_RqhXeuBbHH2CD9reTyOL8H A3n9pVAFBZaLve_8YwKVyOU82DzgbPsib0l461qapQBEksmBatqhRU8lC_bNnCZc29xwVDPV5Igb fVDyuoeE- Received: from sonicgw.mail.yahoo.co.jp by sonicconh5003.mail.kks.yahoo.co.jp with HTTP; Wed, 11 Jan 2023 04:20:48 +0000 Received: by smtphe5006.mail.kks.ynwp.yahoo.co.jp (YJ Hermes SMTP Server) with ESMTPA ID 3f894a3f5b2d636d6ccb9d9c77814dcd; Wed, 11 Jan 2023 13:20:45 +0900 (JST) Message-ID: <076a3744-f608-6f31-7244-2bf7ab06cdb1@yahoo.co.jp> Date: Wed, 11 Jan 2023 13:20:42 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 To: GCC Patches Subject: [PATCH] ifcvt.cc: Prevent excessive if-conversion for conditional moves References: <076a3744-f608-6f31-7244-2bf7ab06cdb1.ref@yahoo.co.jp> X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, 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: Takayuki 'January June' Suwa via Gcc-patches From: Takayuki 'January June' Suwa Reply-To: Takayuki 'January June' Suwa Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Currently, cond_move_process_if_block() does the conversion without balancing the cost of the converted sequence with the original one, but this should be checked by calling targetm.noce_conversion_profitable_p(). Doing so allows us to provide a way based on the target-specific cost estimate, to prevent unwanted size growth due to excessive conditional moves on optimizing for size. On optimizing for speed, default_noce_conversion_profitable_p() allows plenty of headroom, so this patch has little impact. Also, if the target-specific cost estimate is accurate or allows for margins, the impact should be similarly small. gcc/ChangeLog: * ifcvt.cc (cond_move_process_if_block): Consider the result of targetm.noce_conversion_profitable_p() when replacing the original sequence with the converted one. --- gcc/ifcvt.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/ifcvt.cc b/gcc/ifcvt.cc index 008796838f7..a896e14bb3c 100644 --- a/gcc/ifcvt.cc +++ b/gcc/ifcvt.cc @@ -4350,7 +4350,7 @@ cond_move_process_if_block (struct noce_if_info *if_info) goto done; } seq = end_ifcvt_sequence (if_info); - if (!seq) + if (!seq || !targetm.noce_conversion_profitable_p (seq, if_info)) goto done; loc_insn = first_active_insn (then_bb);