public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Takayuki 'January June' Suwa <jjsuwa_sys3175@yahoo.co.jp>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: [PATCH] ifcvt.cc: Prevent excessive if-conversion for conditional moves
Date: Wed, 11 Jan 2023 13:20:42 +0900	[thread overview]
Message-ID: <076a3744-f608-6f31-7244-2bf7ab06cdb1@yahoo.co.jp> (raw)
In-Reply-To: <076a3744-f608-6f31-7244-2bf7ab06cdb1.ref@yahoo.co.jp>

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);
-- 
2.30.2

       reply	other threads:[~2023-01-11  4:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <076a3744-f608-6f31-7244-2bf7ab06cdb1.ref@yahoo.co.jp>
2023-01-11  4:20 ` Takayuki 'January June' Suwa [this message]
2023-01-11  8:02   ` Robin Dapp
2023-01-12  3:34     ` Takayuki 'January June' Suwa
2023-03-11 16:30   ` Jeff Law
2023-04-18 20:12   ` Jeff Law

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=076a3744-f608-6f31-7244-2bf7ab06cdb1@yahoo.co.jp \
    --to=jjsuwa_sys3175@yahoo.co.jp \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).