From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] Fix PR56118
Date: Tue, 10 Nov 2015 09:34:00 -0000 [thread overview]
Message-ID: <alpine.LSU.2.11.1511101033150.10078@zhemvz.fhfr.qr> (raw)
The following fixes PR56118 by adjusting the cost model handling of
basic-block vectorization to favor the vectorized version in case
estimated cost is the same as the estimated cost of the scalar
version. This makes sense because we over-estimate the vectorized
cost in several places.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.
Richard.
2015-11-10 Richard Biener <rguenther@suse.de>
PR tree-optimization/56118
* tree-vect-slp.c (vect_bb_vectorization_profitable_p): Make equal
cost favor vectorized version.
* gcc.target/i386/pr56118.c: New testcase.
Index: gcc/tree-vect-slp.c
===================================================================
--- gcc/tree-vect-slp.c (revision 230020)
+++ gcc/tree-vect-slp.c (working copy)
@@ -2317,9 +2317,12 @@ vect_bb_vectorization_profitable_p (bb_v
dump_printf (MSG_NOTE, " Scalar cost of basic block: %d\n", scalar_cost);
}
- /* Vectorization is profitable if its cost is less than the cost of scalar
- version. */
- if (vec_outside_cost + vec_inside_cost >= scalar_cost)
+ /* Vectorization is profitable if its cost is more than the cost of scalar
+ version. Note that we err on the vector side for equal cost because
+ 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)
return false;
return true;
Index: gcc/testsuite/gcc.target/i386/pr56118.c
===================================================================
--- gcc/testsuite/gcc.target/i386/pr56118.c (revision 0)
+++ gcc/testsuite/gcc.target/i386/pr56118.c (working copy)
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -msse2" } */
+
+#include <emmintrin.h>
+
+__m128d f()
+{
+ __m128d r={3,4};
+ r[0]=1;
+ r[1]=2;
+ return r;
+}
+
+/* We want to "vectorize" this to a aligned vector load from the
+ constant pool. */
+
+/* { dg-final { scan-assembler "movapd" } } */
next reply other threads:[~2015-11-10 9:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-10 9:34 Richard Biener [this message]
2015-11-13 18:05 ` Alan Lawrence
2015-11-16 8:39 ` Richard Biener
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=alpine.LSU.2.11.1511101033150.10078@zhemvz.fhfr.qr \
--to=rguenther@suse.de \
--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).