public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/35386]  New: Invalid vector code generated with -O2
@ 2008-02-26 23:11 kes at smolek dot com
  2008-02-26 23:18 ` [Bug c++/35386] " kes at smolek dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: kes at smolek dot com @ 2008-02-26 23:11 UTC (permalink / raw)
  To: gcc-bugs

A simple vector addition loop fails to generate any addition code when -O2
optimization is used; the loop is essentially empty.


-- 
           Summary: Invalid vector code generated with -O2
           Product: gcc
           Version: 4.2.3
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kes at smolek dot com
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35386


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

* [Bug c++/35386] Invalid vector code generated with -O2
  2008-02-26 23:11 [Bug c++/35386] New: Invalid vector code generated with -O2 kes at smolek dot com
@ 2008-02-26 23:18 ` kes at smolek dot com
  2008-02-26 23:21 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: kes at smolek dot com @ 2008-02-26 23:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from kes at smolek dot com  2008-02-26 23:17 -------
Created an attachment (id=15234)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15234&action=view)
temp file output demonstrating the bug

Command line: gcc -v -save-temps -O2 -S -msse3 ComputeEven.cpp

Note: bug occurs on 4.2.1, 4.2.2; 4.1.2 works okay.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35386


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

* [Bug c++/35386] Invalid vector code generated with -O2
  2008-02-26 23:11 [Bug c++/35386] New: Invalid vector code generated with -O2 kes at smolek dot com
  2008-02-26 23:18 ` [Bug c++/35386] " kes at smolek dot com
@ 2008-02-26 23:21 ` pinskia at gcc dot gnu dot org
  2008-02-27  1:51 ` kes at smolek dot com
  2008-02-27  2:00 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-02-26 23:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2008-02-26 23:20 -------
You are violating C/C++ aliasing rules:

typedef float v4sf __attribute__ ((vector_size(16)));
 v4sf vSum;
 complex<float> *vp = (complex<float> *) &vSum;
...

   spectra[4*j] = vp[0];
   spectra[4*j+2] = vp[1];


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|major                       |normal
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35386


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

* [Bug c++/35386] Invalid vector code generated with -O2
  2008-02-26 23:11 [Bug c++/35386] New: Invalid vector code generated with -O2 kes at smolek dot com
  2008-02-26 23:18 ` [Bug c++/35386] " kes at smolek dot com
  2008-02-26 23:21 ` pinskia at gcc dot gnu dot org
@ 2008-02-27  1:51 ` kes at smolek dot com
  2008-02-27  2:00 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: kes at smolek dot com @ 2008-02-27  1:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from kes at smolek dot com  2008-02-27 01:50 -------
Subject: Re:  Invalid vector code generated with -O2

Oops.  Sorry for the false alarm.  But shouldn't there be an error, or 
at least a warning?

pinskia at gcc dot gnu dot org wrote:
> ------- Comment #2 from pinskia at gcc dot gnu dot org  2008-02-26 23:20 -------
> You are violating C/C++ aliasing rules:
>
> typedef float v4sf __attribute__ ((vector_size(16)));
>  v4sf vSum;
>  complex<float> *vp = (complex<float> *) &vSum;
> ...
>
>    spectra[4*j] = vp[0];
>    spectra[4*j+2] = vp[1];
>
>
>   


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35386


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

* [Bug c++/35386] Invalid vector code generated with -O2
  2008-02-26 23:11 [Bug c++/35386] New: Invalid vector code generated with -O2 kes at smolek dot com
                   ` (2 preceding siblings ...)
  2008-02-27  1:51 ` kes at smolek dot com
@ 2008-02-27  2:00 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-02-27  2:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pinskia at gcc dot gnu dot org  2008-02-27 01:59 -------
(In reply to comment #3)
> Subject: Re:  Invalid vector code generated with -O2
> 
> Oops.  Sorry for the false alarm.  But shouldn't there be an error, or 
> at least a warning?

There should be a warning but sometimes getting warnings for undefined behavior
is hard.

-- Pinski


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35386


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

end of thread, other threads:[~2008-02-27  2:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-26 23:11 [Bug c++/35386] New: Invalid vector code generated with -O2 kes at smolek dot com
2008-02-26 23:18 ` [Bug c++/35386] " kes at smolek dot com
2008-02-26 23:21 ` pinskia at gcc dot gnu dot org
2008-02-27  1:51 ` kes at smolek dot com
2008-02-27  2:00 ` pinskia at gcc dot gnu dot 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).