public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, i386] Avoid SLP vectorization if vector and scalar costs are equal.
@ 2017-12-27 13:00 Shalnov, Sergey
  2017-12-27 17:20 ` Marc Glisse
  0 siblings, 1 reply; 2+ messages in thread
From: Shalnov, Sergey @ 2017-12-27 13:00 UTC (permalink / raw)
  To: 'gcc-patches@gcc.gnu.org'
  Cc: Koval, Julia, Peryt, Sebastian, Ivchenko, Alexander,
	'Uros Bizjak',
	Kirill Yukhin

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

Hi,
Should we use vector instructions if the scalar and vector costs in SLP are the same?
According to the source line comment (already in source code) we should not
use vector instructions in this case.

I would like to propose to use scalars if costs are the same.

Sergey

2017-12-27  Sergey Shalnov  <Sergey.Shalnov@intel.com>
gcc/
	* tree-vect-slp.c (vect_bb_vectorization_profitable_p):
	Avoid SLP vectorization if vector and scalar costs are
	equal.



[-- Attachment #2: 0010-SLP-vectorizeing-decision.patch --]
[-- Type: application/octet-stream, Size: 830 bytes --]

From 054038633b2b23ed5a4e9d226dc4ffa054c0e4c9 Mon Sep 17 00:00:00 2001
From: Sergey Shalnov <Sergey.Shalnov@intel.com>
Date: Wed, 27 Dec 2017 15:46:30 +0300
Subject: [PATCH 1/1] SLP vectorizeing decision

---
 gcc/tree-vect-slp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index 0ca42b4..c2475b7 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -2820,7 +2820,7 @@ vect_bb_vectorization_profitable_p (bb_vec_info bb_vinfo)
      the cost estimate is otherwise quite pessimistic (constant uses are
      free on the scalar side but cost a load on the vector side for
      example).  */
-  if (vec_outside_cost + vec_inside_cost > scalar_cost)
+  if (vec_outside_cost + vec_inside_cost >= scalar_cost)
     return false;
 
   return true;
-- 
1.8.3.1


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

* Re: [PATCH, i386] Avoid SLP vectorization if vector and scalar costs are equal.
  2017-12-27 13:00 [PATCH, i386] Avoid SLP vectorization if vector and scalar costs are equal Shalnov, Sergey
@ 2017-12-27 17:20 ` Marc Glisse
  0 siblings, 0 replies; 2+ messages in thread
From: Marc Glisse @ 2017-12-27 17:20 UTC (permalink / raw)
  To: Shalnov, Sergey
  Cc: 'gcc-patches@gcc.gnu.org',
	Koval, Julia, Peryt, Sebastian, Ivchenko, Alexander,
	'Uros Bizjak',
	Kirill Yukhin

(this isn't an i386 patch)

On Wed, 27 Dec 2017, Shalnov, Sergey wrote:

> Should we use vector instructions if the scalar and vector costs in SLP are the same?
> According to the source line comment (already in source code) we should not
> use vector instructions in this case.

"Vectorization is profitable if its cost is more than the cost of scalar 
version." This existing comment clearly has a typo, it should be "less" or 
"not more".

"Note that we err on the vector side for equal cost because [...]"

So this is clearly done on purpose, and you cannot change the behavior 
without changing the comment as well.

> I would like to propose to use scalars if costs are the same.

Why? The comment explains why the opposite makes sense (costs tend to 
be overestimated in the vector case). Did you measure improvements in some 
benchmark? Can you share a testcase? Did you check if it passes the 
testsuite (I don't remember if there is a specific testcase for this)?

-- 
Marc Glisse

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

end of thread, other threads:[~2017-12-27 17:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-27 13:00 [PATCH, i386] Avoid SLP vectorization if vector and scalar costs are equal Shalnov, Sergey
2017-12-27 17:20 ` Marc Glisse

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