public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/55027] New: simplify vector multiplication by 1
@ 2012-10-22 19:06 glisse at gcc dot gnu.org
2012-10-23 9:42 ` [Bug middle-end/55027] " rguenth at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: glisse at gcc dot gnu.org @ 2012-10-22 19:06 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55027
Bug #: 55027
Summary: simplify vector multiplication by 1
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: glisse@gcc.gnu.org
Hello,
vector multiplication by 1 is not simplified at the tree level.
#include <x86intrin.h>
__m128d f(__m128d x){
__m128d y={1,1};
return x*y;
}
Worse, gcc can actually create such multiplies. In this modified version of
PR55016:
#include <math.h>
float v0[1024];
float v1[1024];
void v() {
for(int i=0; i!=1024; ++i)
v0[i] = 1/sqrtf(v1[i]);
}
compiled on x86_64 with gcc -O3 -ffast-math e.c -S -std=gnu99
*.optimized still shows:
vect_var_.9_23 = vect_var_.8_21 * { 1.0e+0, 1.0e+0, 1.0e+0, 1.0e+0 };
The back-end later removes it, but it should also be handled at tree level.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/55027] simplify vector multiplication by 1
2012-10-22 19:06 [Bug middle-end/55027] New: simplify vector multiplication by 1 glisse at gcc dot gnu.org
@ 2012-10-23 9:42 ` rguenth at gcc dot gnu.org
2012-10-24 19:35 ` glisse at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-10-23 9:42 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55027
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Keywords| |missed-optimization
Last reconfirmed| |2012-10-23
CC| |rguenth at gcc dot gnu.org
Ever Confirmed|0 |1
Severity|normal |enhancement
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> 2012-10-23 09:41:54 UTC ---
For integer values the generic folding with
if (! FLOAT_TYPE_P (type))
{
if (integer_zerop (arg1))
return omit_one_operand_loc (loc, type, arg1, arg0);
if (integer_onep (arg1))
return non_lvalue_loc (loc, fold_convert_loc (loc, type, arg0));
catches this. For float values we have
/* Maybe fold x * 0 to 0. The expressions aren't the same
when x is NaN, since x * 0 is also NaN. Nor are they the
same in modes with signed zeros, since multiplying a
negative value by 0 gives -0, not +0. */
if (!HONOR_NANS (TYPE_MODE (TREE_TYPE (arg0)))
&& !HONOR_SIGNED_ZEROS (TYPE_MODE (TREE_TYPE (arg0)))
&& real_zerop (arg1))
return omit_one_operand_loc (loc, type, arg1, arg0);
/* In IEEE floating point, x*1 is not equivalent to x for snans.
Likewise for complex arithmetic with signed zeros. */
if (!HONOR_SNANS (TYPE_MODE (TREE_TYPE (arg0)))
&& (!HONOR_SIGNED_ZEROS (TYPE_MODE (TREE_TYPE (arg0)))
|| !COMPLEX_FLOAT_TYPE_P (TREE_TYPE (arg0)))
&& real_onep (arg1))
return non_lvalue_loc (loc, fold_convert_loc (loc, type, arg0));
but neiter real_zerop or real_onep handle vector types (there are more
predicates like that). I adjusted the integer predicates to also handle
vector types, so I suppose the same needs to be done for the real predicates.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/55027] simplify vector multiplication by 1
2012-10-22 19:06 [Bug middle-end/55027] New: simplify vector multiplication by 1 glisse at gcc dot gnu.org
2012-10-23 9:42 ` [Bug middle-end/55027] " rguenth at gcc dot gnu.org
@ 2012-10-24 19:35 ` glisse at gcc dot gnu.org
2012-10-29 17:17 ` glisse at gcc dot gnu.org
2012-10-29 17:20 ` glisse at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: glisse at gcc dot gnu.org @ 2012-10-24 19:35 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55027
--- Comment #2 from Marc Glisse <glisse at gcc dot gnu.org> 2012-10-24 19:35:03 UTC ---
Created attachment 28525
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28525
patch
Surprisingly enough, the attached patch doesn't cause any regression in the
testsuite (default languages). I'll add a simple testcase and submit it.
Some remaining predicates that don't handle vectors are integer_nonzerop,
integer_pow2p, but some adaptations are necessary in the users before they can
be changed (at least for pow2p).
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/55027] simplify vector multiplication by 1
2012-10-22 19:06 [Bug middle-end/55027] New: simplify vector multiplication by 1 glisse at gcc dot gnu.org
2012-10-23 9:42 ` [Bug middle-end/55027] " rguenth at gcc dot gnu.org
2012-10-24 19:35 ` glisse at gcc dot gnu.org
@ 2012-10-29 17:17 ` glisse at gcc dot gnu.org
2012-10-29 17:20 ` glisse at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: glisse at gcc dot gnu.org @ 2012-10-29 17:17 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55027
--- Comment #3 from Marc Glisse <glisse at gcc dot gnu.org> 2012-10-29 17:17:01 UTC ---
Author: glisse
Date: Mon Oct 29 17:16:51 2012
New Revision: 192954
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=192954
Log:
2012-10-29 Marc Glisse <marc.glisse@inria.fr>
PR middle-end/55027
gcc/
* tree.c (real_zerop, real_onep, real_twop, real_minus_onep):
Handle VECTOR_CST.
testsuite/
* gcc.dg/pr55027.c: New testcase.
Added:
trunk/gcc/testsuite/gcc.dg/pr55027.c (with props)
Modified:
trunk/gcc/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree.c
Propchange: trunk/gcc/testsuite/gcc.dg/pr55027.c
('svn:eol-style' added)
Propchange: trunk/gcc/testsuite/gcc.dg/pr55027.c
('svn:keywords' added)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/55027] simplify vector multiplication by 1
2012-10-22 19:06 [Bug middle-end/55027] New: simplify vector multiplication by 1 glisse at gcc dot gnu.org
` (2 preceding siblings ...)
2012-10-29 17:17 ` glisse at gcc dot gnu.org
@ 2012-10-29 17:20 ` glisse at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: glisse at gcc dot gnu.org @ 2012-10-29 17:20 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55027
Marc Glisse <glisse at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
--- Comment #4 from Marc Glisse <glisse at gcc dot gnu.org> 2012-10-29 17:20:37 UTC ---
Fixed.
See this email for potential bugs introduced by this patch:
http://gcc.gnu.org/ml/gcc-patches/2012-10/msg02596.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-10-29 17:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-22 19:06 [Bug middle-end/55027] New: simplify vector multiplication by 1 glisse at gcc dot gnu.org
2012-10-23 9:42 ` [Bug middle-end/55027] " rguenth at gcc dot gnu.org
2012-10-24 19:35 ` glisse at gcc dot gnu.org
2012-10-29 17:17 ` glisse at gcc dot gnu.org
2012-10-29 17:20 ` glisse 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).