public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-2049] Improved gain calculation for COMPARE to 0 or -1 in TImode STV on x86_64.
@ 2022-08-15 16:44 Roger Sayle
  0 siblings, 0 replies; only message in thread
From: Roger Sayle @ 2022-08-15 16:44 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:6f94923dea21bd92ba2fc40c4a3be509bb1b7f0c

commit r13-2049-g6f94923dea21bd92ba2fc40c4a3be509bb1b7f0c
Author: Roger Sayle <roger@nextmovesoftware.com>
Date:   Mon Aug 15 17:43:02 2022 +0100

    Improved gain calculation for COMPARE to 0 or -1 in TImode STV on x86_64.
    
    This patch tweaks timode_scalar_chain::compute_convert_gain to provide
    more accurate costs for converting TImode comparisons against zero or
    minus 1 to V1TImode equivalents.
    
    2022-08-15  Roger Sayle  <roger@nextmovesoftware.com>
    
    gcc/ChangeLog
            * config/i386/i386-features.cc
            (timode_scalar_chain::compute_convert_gain): Provide gains for
            comparisons against 0/-1, including "*testti" patterns.

Diff:
---
 gcc/config/i386/i386-features.cc | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc
index effc2f24494..28914de0ac2 100644
--- a/gcc/config/i386/i386-features.cc
+++ b/gcc/config/i386/i386-features.cc
@@ -1250,6 +1250,23 @@ timode_scalar_chain::compute_convert_gain ()
 					      : COSTS_N_INSNS (1);
 	  break;
 
+	case COMPARE:
+	  if (XEXP (src, 1) == const0_rtx)
+	    {
+	      if (GET_CODE (XEXP (src, 0)) == AND)
+		/* and;and;or (9 bytes) vs. ptest (5 bytes).  */
+		igain = optimize_insn_for_size_p() ? COSTS_N_BYTES (4)
+						   : COSTS_N_INSNS (2);
+	      /* or (3 bytes) vs. ptest (5 bytes).  */
+	      else if (optimize_insn_for_size_p ())
+		igain = -COSTS_N_BYTES (2);
+	    }
+	  else if (XEXP (src, 1) == const1_rtx)
+	    /* and;cmp -1 (7 bytes) vs. pcmpeqd;pxor;ptest (13 bytes).  */
+	    igain = optimize_insn_for_size_p() ? -COSTS_N_BYTES (6)
+					       : -COSTS_N_INSNS (1);
+	  break;
+
 	default:
 	  break;
 	}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-08-15 16:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-15 16:44 [gcc r13-2049] Improved gain calculation for COMPARE to 0 or -1 in TImode STV on x86_64 Roger Sayle

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).