[Bug c++/56221] New: Generation of zero initializer for array new without parenthesis

2013-02-06 Thread neldev.online at gmail dot com


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



 Bug #: 56221

   Summary: Generation of zero initializer for array new without

parenthesis

Classification: Unclassified

   Product: gcc

   Version: 4.7.2

Status: UNCONFIRMED

  Severity: normal

  Priority: P3

 Component: c++

AssignedTo: unassig...@gcc.gnu.org

ReportedBy: neldev.onl...@gmail.com





Created attachment 29364

  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29364

Minimal test case



I could not find a duplicate so I guess this will be my first bug report for a

compiler :)



I was experimenting a little with expressive templates and stumbled upon a

peculiar bug that caused assembly output to explode by several orders of

magnitude. I managed to narrow it down to automatic vectorization of a zero

initializer that transformed a 4-instruction memset into some monstrosity.

Recompiling with -fno-tree-vectorize prevents this transformation.



However, the issue of this initializer which generated the memset still

remained.



I've attached a minimal test case that performs the following:

- Trigger unwanted generation of the array initializer.

- Triggering automatic vectorization at will by increasing the parameter to

array new beyond 16.

- Preventing the array initializer from being generated by uncommenting the

second constructor.

- Producing identical results by forcing array initializer generation by

uncommenting the third constructor.



A workaround would b to move the array new statement out of the constructor.



I'm not sure but this seems to be the result of some foul play between the CRTP

pattern and operator+. Removing either will prevent this bug from being

triggered.


[Bug c++/56221] Generation of zero initializer for array new without parenthesis

2013-02-06 Thread neldev.online at gmail dot com


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



--- Comment #1 from neldev.online at gmail dot com 2013-02-06 09:25:42 UTC ---

Created attachment 29365

  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29365

Assembly output showing consecutive mov's for zero initialization


[Bug c++/56221] Generation of zero initializer for array new without parenthesis

2013-02-06 Thread neldev.online at gmail dot com


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



--- Comment #2 from neldev.online at gmail dot com 2013-02-06 09:26:27 UTC ---

I've attached assembly output with -S -fverbose-asm as well.



It has been compiled with:

-O3 -Winline -Wextra -Wall -fno-exceptions -fno-rtti -fomit-frame-pointer

-fexpensive-optimizations



16 consecutive mov instructions can be clearly seen.