public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Bernd Schmidt <bschmidt@redhat.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>, Uros Bizjak <ubizjak@gmail.com>
Subject: Re: [0/3] Fix PR78120, in ifcvt/rtlanal/i386.
Date: Wed, 23 Nov 2016 19:01:00 -0000	[thread overview]
Message-ID: <90a82189-d776-c568-0989-dd33b121337a@redhat.com> (raw)
In-Reply-To: <e6d06b7a-831b-299a-5c5a-507e267238a4@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 319 bytes --]

On 11/23/2016 07:57 PM, Bernd Schmidt wrote:
> 2. The i386 backend mishandles SET rtxs. If you have a fairly plain
> single-insn SET, you tend to get COSTS_N_INSNS (2) out of set_rtx_cost,
> because rtx_costs has a default of COSTS_N_INSNS (1) for a SET, and you
> get the cost of the src in addition to that.


Bernd


[-- Attachment #2: 71280-2.diff --]
[-- Type: text/x-patch, Size: 1312 bytes --]

	PR rtl-optimization/78120
	* config/i386/i386.c (ix86_rtx_costs): Fully handle SETs.

Index: gcc/config/i386/i386.c
===================================================================
--- gcc/config/i386/i386.c	(revision 242038)
+++ gcc/config/i386/i386.c	(working copy)
@@ -39925,6 +39925,7 @@ ix86_rtx_costs (rtx x, machine_mode mode
   enum rtx_code code = GET_CODE (x);
   enum rtx_code outer_code = (enum rtx_code) outer_code_i;
   const struct processor_costs *cost = speed ? ix86_cost : &ix86_size_cost;
+  int src_cost;
 
   switch (code)
     {
@@ -39935,7 +39936,23 @@ ix86_rtx_costs (rtx x, machine_mode mode
 	  *total = ix86_set_reg_reg_cost (GET_MODE (SET_DEST (x)));
 	  return true;
 	}
-      return false;
+
+      if (register_operand (SET_SRC (x), VOIDmode))
+	/* Avoid potentially incorrect high cost from rtx_costs
+	   for non-tieable SUBREGs.  */
+	src_cost = 0;
+      else
+	{
+	  src_cost = rtx_cost (SET_SRC (x), mode, SET, 1, speed);
+
+	  if (CONSTANT_P (SET_SRC (x)))
+	    /* Constant costs assume a base value of COSTS_N_INSNS (1) and add
+	       a small value, possibly zero for cheap constants.  */
+	    src_cost += COSTS_N_INSNS (1);
+	}
+
+      *total = src_cost + rtx_cost (SET_DEST (x), mode, SET, 0, speed);
+      return true;
 
     case CONST_INT:
     case CONST:

  parent reply	other threads:[~2016-11-23 19:01 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-23 18:58 [0/3] Fix PR71280, " Bernd Schmidt
2016-11-23 19:00 ` [0/3] Fix PR78120, " Bernd Schmidt
2016-11-23 19:30   ` Jeff Law
2016-11-23 19:31     ` Bernd Schmidt
2016-11-24 14:21   ` Segher Boessenkool
2016-11-24 14:26     ` Bernd Schmidt
2016-11-24 14:36       ` Segher Boessenkool
2016-11-24 14:38         ` Bernd Schmidt
2016-11-24 14:44           ` Eric Botcazou
2016-11-24 14:54           ` Segher Boessenkool
2016-11-24 15:16             ` Richard Biener
2016-11-24 15:46               ` Jeff Law
2016-11-24 15:34             ` Bernd Schmidt
2016-11-24 15:48             ` Jeff Law
2016-11-24 16:14               ` Segher Boessenkool
2016-11-24 22:32                 ` Segher Boessenkool
2016-11-26 10:44                   ` Jeff Law
2016-11-26 11:11                     ` Eric Botcazou
2016-11-26 16:15                       ` Jeff Law
2016-11-26 22:03                         ` Segher Boessenkool
2016-11-26 18:08                     ` Segher Boessenkool
2016-11-25  9:15                 ` Richard Biener
2016-11-25 15:34                   ` Jeff Law
2016-11-25 15:55                   ` Segher Boessenkool
2016-11-28  8:59                     ` Bernd Schmidt
2016-11-28  9:05                     ` Bernd Schmidt
2016-11-28 18:50                 ` Jeff Law
2016-11-28 18:52                   ` Bernd Schmidt
2016-11-23 19:01 ` Bernd Schmidt [this message]
2016-11-23 21:46   ` Uros Bizjak
2016-11-23 19:03 ` [3/3] " Bernd Schmidt
2016-11-23 19:38   ` 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=90a82189-d776-c568-0989-dd33b121337a@redhat.com \
    --to=bschmidt@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=ubizjak@gmail.com \
    /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).