public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/49483] New: unable to vectorize code equivalent to "scalbnf"
@ 2011-06-21 9:04 vincenzo.innocente at cern dot ch
2011-06-21 9:27 ` [Bug tree-optimization/49483] " rguenth at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: vincenzo.innocente at cern dot ch @ 2011-06-21 9:04 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49483
Summary: unable to vectorize code equivalent to "scalbnf"
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: tree-optimization
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: vincenzo.innocente@cern.ch
I'm trying to write simplified versions of trigonometric and trascendental
functions that gcc can auto-vectorize.
at the moment I'm blocked with the vectorization of "scalbnf"
I'm using code equivalent to the one in glibc
sysdeps/ieee754/flt-32/s_scalbnf.c
and
math/math_private.h
which in my c++ version reads
cat vldexpf.cc
inline float i2f(int x) {
union { float f; int i; } tmp;
tmp.i=x;
return tmp.f;
}
inline float vect_ldexpf(float x, int n) {
n = (n+0x7f)<<23;
return x * i2f(n);
}
float __attribute__ ((aligned(16))) a[1024];
float __attribute__ ((aligned(16))) b[1024];
float __attribute__ ((aligned(16))) c[1024];
void tV() {
for (int i=0; i!=1024; ++i) {
float z = a[i];
int n = b[i];
c[i] = vect_ldexpf(z,n);
}
}
compiling it produces
c++ -Ofast -c vldexpf.cc -msse4.2 -ftree-vectorizer-verbose=7
vldexpf.cc:16: note: vect_model_load_cost: aligned.
vldexpf.cc:16: note: vect_get_data_access_cost: inside_cost = 1, outside_cost =
0.
vldexpf.cc:16: note: vect_model_load_cost: aligned.
vldexpf.cc:16: note: vect_get_data_access_cost: inside_cost = 2, outside_cost =
0.
vldexpf.cc:16: note: vect_model_store_cost: aligned.
vldexpf.cc:16: note: vect_get_data_access_cost: inside_cost = 3, outside_cost =
0.
vldexpf.cc:16: note: vect_model_load_cost: aligned.
vldexpf.cc:16: note: vect_model_load_cost: inside_cost = 1, outside_cost = 0 .
vldexpf.cc:16: note: vect_model_load_cost: aligned.
vldexpf.cc:16: note: vect_model_load_cost: inside_cost = 1, outside_cost = 0 .
vldexpf.cc:16: note: vect_model_simple_cost: inside_cost = 1, outside_cost = 1
.
vldexpf.cc:16: note: vect_model_simple_cost: inside_cost = 1, outside_cost = 1
.
vldexpf.cc:16: note: not vectorized: relevant stmt not supported: D.2243_14 =
VIEW_CONVERT_EXPR<float>(n_13);
vldexpf.cc:15: note: vectorized 0 loops in function.
I'm using
c++ -v
Using built-in specs.
COLLECT_GCC=c++
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-apple-darwin10.7.0/4.7.0/lto-wrapper
Target: x86_64-apple-darwin10.7.0
Configured with: ./configure --enable-languages=c,c++,fortran --enable-lto
--with-build-config=bootstrap-lto CFLAGS='-O2 -ftree-vectorize -fPIC'
CXXFLAGS='-O2 -fPIC -ftree-vectorize -fvisibility-inlines-hidden'
Thread model: posix
gcc version 4.7.0 20110528 (experimental) (GCC)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/49483] unable to vectorize code equivalent to "scalbnf"
2011-06-21 9:04 [Bug tree-optimization/49483] New: unable to vectorize code equivalent to "scalbnf" vincenzo.innocente at cern dot ch
@ 2011-06-21 9:27 ` rguenth at gcc dot gnu.org
2011-06-21 10:42 ` vincenzo.innocente at cern dot ch
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-06-21 9:27 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49483
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2011.06.21 09:26:57
AssignedTo|unassigned at gcc dot |rguenth at gcc dot gnu.org
|gnu.org |
Ever Confirmed|0 |1
--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-06-21 09:26:57 UTC ---
We at the moment only handle sign-changes, but obviously
we in principle can handle all VIEW_CONVERT_EXPRs.
I'm testing the following, which works for your testcase.
Index: gcc/tree-vect-stmts.c
===================================================================
--- gcc/tree-vect-stmts.c (revision 175205)
+++ gcc/tree-vect-stmts.c (working copy)
@@ -2089,6 +2089,9 @@ vectorizable_assignment (gimple stmt, gi
else
return false;
+ if (code == VIEW_CONVERT_EXPR)
+ op = TREE_OPERAND (op, 0);
+
if (!vect_is_simple_use_1 (op, loop_vinfo, bb_vinfo,
&def_stmt, &def, &dt[0], &vectype_in))
{
@@ -2099,7 +2102,8 @@ vectorizable_assignment (gimple stmt, gi
/* We can handle NOP_EXPR conversions that do not change the number
of elements or the vector size. */
- if (CONVERT_EXPR_CODE_P (code)
+ if ((CONVERT_EXPR_CODE_P (code)
+ || code == VIEW_CONVERT_EXPR)
&& (!vectype_in
|| TYPE_VECTOR_SUBPARTS (vectype_in) != nunits
|| (GET_MODE_SIZE (TYPE_MODE (vectype))
@@ -2134,7 +2138,8 @@ vectorizable_assignment (gimple stmt, gi
/* Arguments are ready. create the new vector stmt. */
FOR_EACH_VEC_ELT (tree, vec_oprnds, i, vop)
{
- if (CONVERT_EXPR_CODE_P (code))
+ if (CONVERT_EXPR_CODE_P (code)
+ || code == VIEW_CONVERT_EXPR)
vop = build1 (VIEW_CONVERT_EXPR, vectype, vop);
new_stmt = gimple_build_assign (vec_dest, vop);
new_temp = make_ssa_name (vec_dest, new_stmt);
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/49483] unable to vectorize code equivalent to "scalbnf"
2011-06-21 9:04 [Bug tree-optimization/49483] New: unable to vectorize code equivalent to "scalbnf" vincenzo.innocente at cern dot ch
2011-06-21 9:27 ` [Bug tree-optimization/49483] " rguenth at gcc dot gnu.org
@ 2011-06-21 10:42 ` vincenzo.innocente at cern dot ch
2011-06-21 10:51 ` rguenther at suse dot de
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: vincenzo.innocente at cern dot ch @ 2011-06-21 10:42 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49483
--- Comment #2 from vincenzo Innocente <vincenzo.innocente at cern dot ch> 2011-06-21 10:42:01 UTC ---
great!
unfortunately
gcc-4.7-20110528 $ patch -p0 < vect.patch
patching file gcc/tree-vect-stmts.c
Hunk #1 FAILED at 2089.
Hunk #2 FAILED at 2099.
Hunk #3 FAILED at 2134.
3 out of 3 hunks FAILED -- saving rejects to file gcc/tree-vect-stmts.c.rej
so I edit gcc/tree-vect-stmts.c by hand
and worked!
vldexpf.cc:16: note: LOOP VECTORIZED.
hope it will make it for 4.6.1 :-)
I'm will wait that it gets in a snapshot to update all my machines to a new
version.
v.
On 21 Jun, 2011, at 11:26 AM, rguenth at gcc dot gnu.org wrote:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49483
>
> Richard Guenther <rguenth at gcc dot gnu.org> changed:
>
> What |Removed |Added
> ----------------------------------------------------------------------------
> Status|UNCONFIRMED |ASSIGNED
> Last reconfirmed| |2011.06.21 09:26:57
> AssignedTo|unassigned at gcc dot |rguenth at gcc dot gnu.org
> |gnu.org |
> Ever Confirmed|0 |1
>
> --- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-06-21 09:26:57 UTC ---
> We at the moment only handle sign-changes, but obviously
> we in principle can handle all VIEW_CONVERT_EXPRs.
>
> I'm testing the following, which works for your testcase.
>
> Index: gcc/tree-vect-stmts.c
> ===================================================================
> --- gcc/tree-vect-stmts.c (revision 175205)
> +++ gcc/tree-vect-stmts.c (working copy)
> @@ -2089,6 +2089,9 @@ vectorizable_assignment (gimple stmt, gi
> else
> return false;
>
> + if (code == VIEW_CONVERT_EXPR)
> + op = TREE_OPERAND (op, 0);
> +
> if (!vect_is_simple_use_1 (op, loop_vinfo, bb_vinfo,
> &def_stmt, &def, &dt[0], &vectype_in))
> {
> @@ -2099,7 +2102,8 @@ vectorizable_assignment (gimple stmt, gi
>
> /* We can handle NOP_EXPR conversions that do not change the number
> of elements or the vector size. */
> - if (CONVERT_EXPR_CODE_P (code)
> + if ((CONVERT_EXPR_CODE_P (code)
> + || code == VIEW_CONVERT_EXPR)
> && (!vectype_in
> || TYPE_VECTOR_SUBPARTS (vectype_in) != nunits
> || (GET_MODE_SIZE (TYPE_MODE (vectype))
> @@ -2134,7 +2138,8 @@ vectorizable_assignment (gimple stmt, gi
> /* Arguments are ready. create the new vector stmt. */
> FOR_EACH_VEC_ELT (tree, vec_oprnds, i, vop)
> {
> - if (CONVERT_EXPR_CODE_P (code))
> + if (CONVERT_EXPR_CODE_P (code)
> + || code == VIEW_CONVERT_EXPR)
> vop = build1 (VIEW_CONVERT_EXPR, vectype, vop);
> new_stmt = gimple_build_assign (vec_dest, vop);
> new_temp = make_ssa_name (vec_dest, new_stmt);
>
> --
> Configure bugmail: http://gcc.gnu.org/bugzilla/userprefs.cgi?tab=email
> ------- You are receiving this mail because: -------
> You reported the bug.
--
Il est bon de suivre sa pente, pourvu que ce soit en montant.
A.G.
http://www.flickr.com/photos/vin60/1320965757/
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/49483] unable to vectorize code equivalent to "scalbnf"
2011-06-21 9:04 [Bug tree-optimization/49483] New: unable to vectorize code equivalent to "scalbnf" vincenzo.innocente at cern dot ch
2011-06-21 9:27 ` [Bug tree-optimization/49483] " rguenth at gcc dot gnu.org
2011-06-21 10:42 ` vincenzo.innocente at cern dot ch
@ 2011-06-21 10:51 ` rguenther at suse dot de
2011-06-21 11:03 ` rguenth at gcc dot gnu.org
2011-06-21 11:04 ` rguenth at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: rguenther at suse dot de @ 2011-06-21 10:51 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49483
--- Comment #3 from rguenther at suse dot de <rguenther at suse dot de> 2011-06-21 10:50:14 UTC ---
On Tue, 21 Jun 2011, vincenzo.innocente at cern dot ch wrote:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49483
>
> --- Comment #2 from vincenzo Innocente <vincenzo.innocente at cern dot ch> 2011-06-21 10:42:01 UTC ---
> great!
>
> unfortunately
> gcc-4.7-20110528 $ patch -p0 < vect.patch
> patching file gcc/tree-vect-stmts.c
> Hunk #1 FAILED at 2089.
> Hunk #2 FAILED at 2099.
> Hunk #3 FAILED at 2134.
> 3 out of 3 hunks FAILED -- saving rejects to file gcc/tree-vect-stmts.c.rej
>
> so I edit gcc/tree-vect-stmts.c by hand
> and worked!
>
> vldexpf.cc:16: note: LOOP VECTORIZED.
>
> hope it will make it for 4.6.1 :-)
Unlikely unless it is a regression ;) It'll make 4.7.0 though if
testing succeeds.
Richard.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/49483] unable to vectorize code equivalent to "scalbnf"
2011-06-21 9:04 [Bug tree-optimization/49483] New: unable to vectorize code equivalent to "scalbnf" vincenzo.innocente at cern dot ch
` (2 preceding siblings ...)
2011-06-21 10:51 ` rguenther at suse dot de
@ 2011-06-21 11:03 ` rguenth at gcc dot gnu.org
2011-06-21 11:04 ` rguenth at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-06-21 11:03 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49483
--- Comment #4 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-06-21 11:02:42 UTC ---
Author: rguenth
Date: Tue Jun 21 11:02:38 2011
New Revision: 175252
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175252
Log:
2011-06-21 Richard Guenther <rguenther@suse.de>
PR tree-optimization/49483
* tree-vect-stmts.c (vectorizable_assignment): Also handle
VIEW_CONVERT_EXPR conversions.
* gcc.dg/vect/vect-120.c: New testcase.
Added:
trunk/gcc/testsuite/gcc.dg/vect/vect-120.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree-vect-stmts.c
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/49483] unable to vectorize code equivalent to "scalbnf"
2011-06-21 9:04 [Bug tree-optimization/49483] New: unable to vectorize code equivalent to "scalbnf" vincenzo.innocente at cern dot ch
` (3 preceding siblings ...)
2011-06-21 11:03 ` rguenth at gcc dot gnu.org
@ 2011-06-21 11:04 ` rguenth at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-06-21 11:04 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49483
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
--- Comment #5 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-06-21 11:03:45 UTC ---
Fixed for 4.7.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-06-21 11:04 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-21 9:04 [Bug tree-optimization/49483] New: unable to vectorize code equivalent to "scalbnf" vincenzo.innocente at cern dot ch
2011-06-21 9:27 ` [Bug tree-optimization/49483] " rguenth at gcc dot gnu.org
2011-06-21 10:42 ` vincenzo.innocente at cern dot ch
2011-06-21 10:51 ` rguenther at suse dot de
2011-06-21 11:03 ` rguenth at gcc dot gnu.org
2011-06-21 11:04 ` rguenth at gcc dot gnu.org
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).