* [Bug c/14319] incorrect optimization of union of structs with common initial sequences
2004-02-27 5:29 [Bug c/14319] New: incorrect optimization of union of structs with common initial sequences jsturm at gcc dot gnu dot org
@ 2004-02-27 8:37 ` rth at gcc dot gnu dot org
2004-02-27 15:19 ` bangerth at dealii dot org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rth at gcc dot gnu dot org @ 2004-02-27 8:37 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From rth at gcc dot gnu dot org 2004-02-27 08:37 -------
As gcc currently reads 6.5.2.3#5, you must actually use the union type
at the point of reference. I.e. u.x.x and u.y.y will be considered to
conflict, as would up->x.x and up->y.y. This implementation detail is
even documented in the -fstrict-aliasing option summary.
Any change in behaviour here will have to wait until DR 257 is resolved.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14319
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c/14319] incorrect optimization of union of structs with common initial sequences
2004-02-27 5:29 [Bug c/14319] New: incorrect optimization of union of structs with common initial sequences jsturm at gcc dot gnu dot org
2004-02-27 8:37 ` [Bug c/14319] " rth at gcc dot gnu dot org
@ 2004-02-27 15:19 ` bangerth at dealii dot org
2004-02-27 19:08 ` jsturm at gcc dot gnu dot org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: bangerth at dealii dot org @ 2004-02-27 15:19 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-02-27 15:19 -------
I can't believe the wording means what you imply. Assume that caller
and callee are in different translation units, then there is no
way for the compiler to see that the two arguments to the called function
may in fact be members of the same union.
So the only way to assume that they could alias each other is to
search the universe for a union type in which both of them are members.
That certainly can't be the intent of the standard or DR. It only makes
sense, if as RTH says the access is through such a union.
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14319
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c/14319] incorrect optimization of union of structs with common initial sequences
2004-02-27 5:29 [Bug c/14319] New: incorrect optimization of union of structs with common initial sequences jsturm at gcc dot gnu dot org
2004-02-27 8:37 ` [Bug c/14319] " rth at gcc dot gnu dot org
2004-02-27 15:19 ` bangerth at dealii dot org
@ 2004-02-27 19:08 ` jsturm at gcc dot gnu dot org
2004-02-27 19:24 ` bangerth at dealii dot org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: jsturm at gcc dot gnu dot org @ 2004-02-27 19:08 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From jsturm at gcc dot gnu dot org 2004-02-27 19:07 -------
(In reply to comment #2)
> I can't believe the wording means what you imply. Assume that caller
> and callee are in different translation units, then there is no
> way for the compiler to see that the two arguments to the called function
> may in fact be members of the same union.
Isn't that the reason for the visibility rule? Read the committee's response to
DR 257.
> So the only way to assume that they could alias each other is to
> search the universe for a union type in which both of them are members.
> That certainly can't be the intent of the standard or DR. It only makes
> sense, if as RTH says the access is through such a union.
Yet it intrigues me then that the committee would have a need to create a
special exception for this one case. In all other situations (type-punning) the
behavior seems to be implementation defined.
The 2nd example in 6.5.2.3#8 is equivalent to mine, except for the scope of the
union declaration.
Despite RTH's comment I don't see any mention of this exception for common
initial sequences in the -fstrict-aliasing docs. There are general examples of
type-punning though.
Anyhow... folks, I don't really care one way or other. I wasn't even aware of
DR 257 prior to Dan Nicolaescu's message. If this is considered settled for GCC
pending any clarification from the committee, then the PR might as well be closed.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14319
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c/14319] incorrect optimization of union of structs with common initial sequences
2004-02-27 5:29 [Bug c/14319] New: incorrect optimization of union of structs with common initial sequences jsturm at gcc dot gnu dot org
` (2 preceding siblings ...)
2004-02-27 19:08 ` jsturm at gcc dot gnu dot org
@ 2004-02-27 19:24 ` bangerth at dealii dot org
2004-02-29 3:19 ` [Bug optimization/14319] [tree-ssa] " pinskia at gcc dot gnu dot org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: bangerth at dealii dot org @ 2004-02-27 19:24 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-02-27 19:24 -------
Leaving aside questions of what the standard actually (is supposed to) mean:
if the aliasing rules are changed as you propose, then
- adding a union somewhere to a code will change the code generated for
the function in your example, even if this union is not actually used
anywhere
- this takes away quite a number of opportunities for optimization, since
it is certainly not uncommon for code to use small structures that have,
say, an integer or pointer as first argument (think iterators and
accessors).
In my eyes, both are not exactly positive consequences. But that's a personal
opinion, not a language lawyer's statement.
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14319
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug optimization/14319] [tree-ssa] incorrect optimization of union of structs with common initial sequences
2004-02-27 5:29 [Bug c/14319] New: incorrect optimization of union of structs with common initial sequences jsturm at gcc dot gnu dot org
` (3 preceding siblings ...)
2004-02-27 19:24 ` bangerth at dealii dot org
@ 2004-02-29 3:19 ` pinskia at gcc dot gnu dot org
2004-03-03 1:05 ` [Bug optimization/14319] " rth at gcc dot gnu dot org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-02-29 3:19 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Component|c |optimization
Summary|incorrect optimization of |[tree-ssa] incorrect
|union of structs with common|optimization of union of
|initial sequences |structs with common initial
| |sequences
Target Milestone|--- |tree-ssa
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14319
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug optimization/14319] incorrect optimization of union of structs with common initial sequences
2004-02-27 5:29 [Bug c/14319] New: incorrect optimization of union of structs with common initial sequences jsturm at gcc dot gnu dot org
` (4 preceding siblings ...)
2004-02-29 3:19 ` [Bug optimization/14319] [tree-ssa] " pinskia at gcc dot gnu dot org
@ 2004-03-03 1:05 ` rth at gcc dot gnu dot org
2004-03-03 1:06 ` rth at gcc dot gnu dot org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rth at gcc dot gnu dot org @ 2004-03-03 1:05 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From rth at gcc dot gnu dot org 2004-03-03 01:05 -------
confirming in order to...
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2004-03-03 01:05:27
date| |
Summary|[tree-ssa] incorrect |incorrect optimization of
|optimization of union of |union of structs with common
|structs with common initial |initial sequences
|sequences |
Target Milestone|tree-ssa |3.5.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14319
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug optimization/14319] incorrect optimization of union of structs with common initial sequences
2004-02-27 5:29 [Bug c/14319] New: incorrect optimization of union of structs with common initial sequences jsturm at gcc dot gnu dot org
` (5 preceding siblings ...)
2004-03-03 1:05 ` [Bug optimization/14319] " rth at gcc dot gnu dot org
@ 2004-03-03 1:06 ` rth at gcc dot gnu dot org
2004-05-27 5:21 ` [Bug rtl-optimization/14319] " pinskia at gcc dot gnu dot org
2005-09-26 15:42 ` pinskia at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: rth at gcc dot gnu dot org @ 2004-03-03 1:06 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From rth at gcc dot gnu dot org 2004-03-03 01:06 -------
... suspend it until we can figure out what the language is supposed to mean.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |SUSPENDED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14319
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug rtl-optimization/14319] incorrect optimization of union of structs with common initial sequences
2004-02-27 5:29 [Bug c/14319] New: incorrect optimization of union of structs with common initial sequences jsturm at gcc dot gnu dot org
` (6 preceding siblings ...)
2004-03-03 1:06 ` rth at gcc dot gnu dot org
@ 2004-05-27 5:21 ` pinskia at gcc dot gnu dot org
2005-09-26 15:42 ` pinskia at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-27 5:21 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|3.5.0 |---
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14319
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug rtl-optimization/14319] incorrect optimization of union of structs with common initial sequences
2004-02-27 5:29 [Bug c/14319] New: incorrect optimization of union of structs with common initial sequences jsturm at gcc dot gnu dot org
` (7 preceding siblings ...)
2004-05-27 5:21 ` [Bug rtl-optimization/14319] " pinskia at gcc dot gnu dot org
@ 2005-09-26 15:42 ` pinskia at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-09-26 15:42 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |alias
Last reconfirmed|2005-05-26 12:37:22 |2005-09-26 15:42:20
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14319
^ permalink raw reply [flat|nested] 10+ messages in thread