* [Bug tree-optimization/55559] Marshalling double through union with inlines, incorrect behavior with -O2
2012-12-01 22:56 [Bug c++/55559] New: Marshalling double through union with inlines, incorrect behavior with -O2 mpreda at gmail dot com
@ 2012-12-02 0:10 ` pinskia at gcc dot gnu.org
2012-12-02 11:16 ` mikpe at it dot uu.se
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-12-02 0:10 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55559
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
Status|UNCONFIRMED |NEW
Last reconfirmed| |2012-12-02
Component|c++ |tree-optimization
Ever Confirmed|0 |1
Known to fail| |4.7.0, 4.8.0
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-12-02 00:09:30 UTC ---
CCP is broken:
Visiting statement:
D.1625_1 = D.1625_8;
Lattice value changed to CONSTANT -4616189618054758400. Adding SSA edges to
worklist.
Visiting statement:
D.1631_7 = VIEW_CONVERT_EXPR<double>(D.1625_1);
which is likely CONSTANT
Lattice value changed to CONSTANT -1.0e+0. Adding SSA edges to worklist.
Visiting statement:
D.1631_9 = D.1631_7;
Lattice value changed to CONSTANT -1.0e+0. Adding SSA edges to worklist.
Visiting statement:
D.1631_2 = D.1631_9;
Lattice value changed to CONSTANT -1.0e+0. Adding SSA edges to worklist.
Visiting statement:
D.1610_3 = (unsigned int) D.1631_2;
which is likely CONSTANT
Lattice value changed to CONSTANT 0. Adding SSA edges to worklist.
I think this is a regression if the code does not use extended initializer
lists but I have not tested it though.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/55559] Marshalling double through union with inlines, incorrect behavior with -O2
2012-12-01 22:56 [Bug c++/55559] New: Marshalling double through union with inlines, incorrect behavior with -O2 mpreda at gmail dot com
2012-12-02 0:10 ` [Bug tree-optimization/55559] " pinskia at gcc dot gnu.org
@ 2012-12-02 11:16 ` mikpe at it dot uu.se
2012-12-02 16:05 ` mikpe at it dot uu.se
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: mikpe at it dot uu.se @ 2012-12-02 11:16 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55559
Mikael Pettersson <mikpe at it dot uu.se> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mikpe at it dot uu.se
--- Comment #2 from Mikael Pettersson <mikpe at it dot uu.se> 2012-12-02 11:15:37 UTC ---
Doesn't depend on that extended initializer, a pure C version fails for me at
-O1 and above with gcc 4.4.7, 4.5.4, 4.6.3, 4.7.2, and trunk, while 4.3.6
works.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/55559] Marshalling double through union with inlines, incorrect behavior with -O2
2012-12-01 22:56 [Bug c++/55559] New: Marshalling double through union with inlines, incorrect behavior with -O2 mpreda at gmail dot com
2012-12-02 0:10 ` [Bug tree-optimization/55559] " pinskia at gcc dot gnu.org
2012-12-02 11:16 ` mikpe at it dot uu.se
@ 2012-12-02 16:05 ` mikpe at it dot uu.se
2012-12-03 11:44 ` [Bug tree-optimization/55559] [4.6/4.7/4.8 Regression] " rguenth at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: mikpe at it dot uu.se @ 2012-12-02 16:05 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55559
--- Comment #3 from Mikael Pettersson <mikpe at it dot uu.se> 2012-12-02 16:04:49 UTC ---
Created attachment 28853
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28853
simplified test case in plain C
The regression started with Richard Biener's "[PATCH] Teach SCCVN/FRE
expression insertion, optimize type-punning through unions (final!)" patch in
r133218:
http://gcc.gnu.org/ml/gcc-patches/2008-03/msg00873.html
http://gcc.gnu.org/ml/gcc-cvs/2008-03/msg00436.html
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/55559] [4.6/4.7/4.8 Regression] Marshalling double through union with inlines, incorrect behavior with -O2
2012-12-01 22:56 [Bug c++/55559] New: Marshalling double through union with inlines, incorrect behavior with -O2 mpreda at gmail dot com
` (2 preceding siblings ...)
2012-12-02 16:05 ` mikpe at it dot uu.se
@ 2012-12-03 11:44 ` rguenth at gcc dot gnu.org
2012-12-03 12:30 ` rguenth at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-12-03 11:44 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55559
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Known to work| |4.3.6
AssignedTo|unassigned at gcc dot |rguenth at gcc dot gnu.org
|gnu.org |
Target Milestone|--- |4.6.4
Summary|Marshalling double through |[4.6/4.7/4.8 Regression]
|union with inlines, |Marshalling double through
|incorrect behavior with -O2 |union with inlines,
| |incorrect behavior with -O2
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> 2012-12-03 11:43:53 UTC ---
Mine then.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/55559] [4.6/4.7/4.8 Regression] Marshalling double through union with inlines, incorrect behavior with -O2
2012-12-01 22:56 [Bug c++/55559] New: Marshalling double through union with inlines, incorrect behavior with -O2 mpreda at gmail dot com
` (3 preceding siblings ...)
2012-12-03 11:44 ` [Bug tree-optimization/55559] [4.6/4.7/4.8 Regression] " rguenth at gcc dot gnu.org
@ 2012-12-03 12:30 ` rguenth at gcc dot gnu.org
2012-12-03 12:52 ` paolo.carlini at oracle dot com
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-12-03 12:30 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55559
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords|wrong-code |
Status|ASSIGNED |RESOLVED
Resolution| |INVALID
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> 2012-12-03 12:30:20 UTC ---
We ask fold_unary to fold
fold_unary_ignore_overflow_loc (loc=2147483655, code=FIX_TRUNC_EXPR,
type=0x7ffff6d17690, op0=0x7ffff6e23858)
at /space/rguenther/src/svn/trunk/gcc/fold-const.c:8363
(gdb) call debug_tree (type)
<integer_type 0x7ffff6d17690 unsigned int public unsigned SI
size <integer_cst 0x7ffff6d1a0c0 type <integer_type 0x7ffff6d170a8
bitsizetype> constant 32>
unit size <integer_cst 0x7ffff6d1a0e0 type <integer_type 0x7ffff6d17000
sizetype> constant 4>
align 32 symtab 0 alias set -1 canonical type 0x7ffff6d17690 precision 32
min <integer_cst 0x7ffff6d1a100 0> max <integer_cst 0x7ffff6d1a0a0 4294967295>
pointer_to_this <pointer_type 0x7ffff6d270a8>>
(gdb) call debug_tree (op0)
<real_cst 0x7ffff6e23858
type <real_type 0x7ffff6d17f18 double sizes-gimplified DF
size <integer_cst 0x7ffff6d02d40 constant 64>
unit size <integer_cst 0x7ffff6d02d60 constant 8>
align 64 symtab 0 alias set -1 canonical type 0x7ffff6d17f18 precision
64
pointer_to_this <pointer_type 0x7ffff6d1f150>>
constant -1.0e+0>
which ends up in fold_convert_const_int_from_real which returns
0 with TREE_OVERFLOW set.
Note that you end up converting the double -1.0 to unsigned which according
to C99 6.3.1.4 ends up invoking undefined behavior.
GCC's behavior is not ill-defined, your testcase is. That behavior changed
is fine as it is unsefined.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/55559] [4.6/4.7/4.8 Regression] Marshalling double through union with inlines, incorrect behavior with -O2
2012-12-01 22:56 [Bug c++/55559] New: Marshalling double through union with inlines, incorrect behavior with -O2 mpreda at gmail dot com
` (4 preceding siblings ...)
2012-12-03 12:30 ` rguenth at gcc dot gnu.org
@ 2012-12-03 12:52 ` paolo.carlini at oracle dot com
2012-12-03 22:13 ` mpreda at gmail dot com
2012-12-04 9:03 ` rguenther at suse dot de
7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-12-03 12:52 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55559
--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-12-03 12:51:45 UTC ---
I knew that a PR using "marshalling" couldn't be right ;)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/55559] [4.6/4.7/4.8 Regression] Marshalling double through union with inlines, incorrect behavior with -O2
2012-12-01 22:56 [Bug c++/55559] New: Marshalling double through union with inlines, incorrect behavior with -O2 mpreda at gmail dot com
` (5 preceding siblings ...)
2012-12-03 12:52 ` paolo.carlini at oracle dot com
@ 2012-12-03 22:13 ` mpreda at gmail dot com
2012-12-04 9:03 ` rguenther at suse dot de
7 siblings, 0 replies; 9+ messages in thread
From: mpreda at gmail dot com @ 2012-12-03 22:13 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55559
--- Comment #7 from Mihai Preda <mpreda at gmail dot com> 2012-12-03 22:13:03 UTC ---
Thanks, I didn't realize that (unsigned)-1.0 is undefined.
For the behavior I was expecting it's enough to use an intermediary cast
through int, e.g. (unsigned)(int)-1.0.
It may be nice to generate a consistent (-O0/-O1) result for (unsigned)-1.0
though, even if not required by the standard.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/55559] [4.6/4.7/4.8 Regression] Marshalling double through union with inlines, incorrect behavior with -O2
2012-12-01 22:56 [Bug c++/55559] New: Marshalling double through union with inlines, incorrect behavior with -O2 mpreda at gmail dot com
` (6 preceding siblings ...)
2012-12-03 22:13 ` mpreda at gmail dot com
@ 2012-12-04 9:03 ` rguenther at suse dot de
7 siblings, 0 replies; 9+ messages in thread
From: rguenther at suse dot de @ 2012-12-04 9:03 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55559
--- Comment #8 from rguenther at suse dot de <rguenther at suse dot de> 2012-12-04 09:02:00 UTC ---
On Mon, 3 Dec 2012, mpreda at gmail dot com wrote:
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55559
>
> --- Comment #7 from Mihai Preda <mpreda at gmail dot com> 2012-12-03 22:13:03 UTC ---
> Thanks, I didn't realize that (unsigned)-1.0 is undefined.
>
> For the behavior I was expecting it's enough to use an intermediary cast
> through int, e.g. (unsigned)(int)-1.0.
Yes, that makes it implementation-defined (and all implementations
I know of do what you expect, modulo-two reduction).
> It may be nice to generate a consistent (-O0/-O1) result for (unsigned)-1.0
> though, even if not required by the standard.
That's unfortunately generally impossible.
^ permalink raw reply [flat|nested] 9+ messages in thread