public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, i386]: Improve STV conversion of shifts
@ 2019-08-28 16:12 Uros Bizjak
  2019-08-29  8:49 ` Uros Bizjak
  0 siblings, 1 reply; 22+ messages in thread
From: Uros Bizjak @ 2019-08-28 16:12 UTC (permalink / raw)
  To: gcc-patches

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

Attached patch improves costing for STV shifts and corrects reject
condition for out of range shift count operands.

2019-08-28  Uroš Bizjak  <ubizjak@gmail.com>

    * config/i386/i386-features.c
    (general_scalar_chain::compute_convert_gain):
    Correct cost for double-word shifts.
    (general_scalar_to_vector_candidate_p): Reject count operands
    greater or equal to mode bitsize.

Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

Committed to mainline SVN.

Uros.

[-- Attachment #2: p.diff.txt --]
[-- Type: text/plain, Size: 1190 bytes --]

diff --git a/gcc/config/i386/i386-features.c b/gcc/config/i386/i386-features.c
index 6eb1482a9f01..766ec355e07b 100644
--- a/gcc/config/i386/i386-features.c
+++ b/gcc/config/i386/i386-features.c
@@ -549,11 +549,18 @@ general_scalar_chain::compute_convert_gain ()
 	       || GET_CODE (src) == ASHIFTRT
 	       || GET_CODE (src) == LSHIFTRT)
 	{
+	  if (m == 2)
+	    {
+	      if (INTVAL (XEXP (src, 1)) >= 32)
+		igain += ix86_cost->add;
+	      else
+		igain += ix86_cost->shift_const;
+	    }
+
+	  igain += ix86_cost->shift_const - ix86_cost->sse_op;
+
 	  if (CONST_INT_P (XEXP (src, 0)))
 	    igain -= vector_const_cost (XEXP (src, 0));
-	  igain += m * ix86_cost->shift_const - ix86_cost->sse_op;
-	  if (INTVAL (XEXP (src, 1)) >= 32)
-	    igain -= COSTS_N_INSNS (1);
 	}
       else if (GET_CODE (src) == PLUS
 	       || GET_CODE (src) == MINUS
@@ -1325,7 +1332,7 @@ general_scalar_to_vector_candidate_p (rtx_insn *insn, enum machine_mode mode)
     case ASHIFT:
     case LSHIFTRT:
       if (!CONST_INT_P (XEXP (src, 1))
-	  || !IN_RANGE (INTVAL (XEXP (src, 1)), 0, 63))
+	  || !IN_RANGE (INTVAL (XEXP (src, 1)), 0, GET_MODE_BITSIZE (mode)-1))
 	return false;
       break;
 

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2019-09-06 19:32 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-28 16:12 [PATCH, i386]: Improve STV conversion of shifts Uros Bizjak
2019-08-29  8:49 ` Uros Bizjak
2019-08-29 10:11   ` [PATCH, i386]: Fix secondary_reload_needed (was: Re: [PATCH, i386]: Improve STV conversion of shifts) Uros Bizjak
2019-08-29 10:17     ` Uros Bizjak
2019-08-30  7:40   ` [PATCH, i386]: Improve STV conversion of shifts Richard Biener
2019-08-30  8:29     ` [PATCH, i386]: Do not limit the cost of moves to/from XMM register to minimum 8 Uros Bizjak
2019-08-31  3:01       ` Alan Modra
2019-08-31 16:12         ` Richard Biener
2019-09-01 19:49           ` Uros Bizjak
2019-09-02  7:16             ` Alan Modra
2019-09-02  8:13             ` Hongtao Liu
2019-09-02  8:41               ` Uros Bizjak
2019-09-03  7:57                 ` Hongtao Liu
2019-09-03 11:24                   ` Richard Biener
2019-09-03 11:33                     ` Richard Biener
2019-09-03 16:50                       ` Uros Bizjak
2019-09-04  1:42                         ` Hongtao Liu
2019-09-05  5:47                           ` Hongtao Liu
2019-09-05  8:54                             ` Uros Bizjak
2019-09-06 19:32                               ` [PATCH, i386]: Fix PR 91654: Runtime SPEC regression on Haswell Uros Bizjak
2019-09-02 10:23               ` [PATCH, i386]: Do not limit the cost of moves to/from XMM register to minimum 8 Richard Biener
2019-09-03  1:37                 ` Hongtao Liu

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