public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ada/37604] New: Suboptimal code generation for volatile access
@ 2008-09-20 20:15 sam at gcc dot gnu dot org
2008-09-21 12:21 ` [Bug ada/37604] " rguenth at gcc dot gnu dot org
2008-09-21 12:25 ` sam at gcc dot gnu dot org
0 siblings, 2 replies; 3+ messages in thread
From: sam at gcc dot gnu dot org @ 2008-09-20 20:15 UTC (permalink / raw)
To: gcc-bugs
The following code generates suboptimal code on i686-pc-linux-gnu:
with Interfaces; use Interfaces;
with System.Storage_Elements;
package A is
Var : unsigned_8;
for Var'Address use System.Storage_Elements.To_Address (1000);
pragma Volatile (Var);
end A;
with A;
with Interfaces; use Interfaces;
procedure U is
begin
A.Var := A.Var or 1;
A.Var := A.Var or 2;
end U;
With -O3 -fomit-frame-pointer, we get:
_ada_u:
movl a__var, %edx <=== indirection instead of...
movzbl (%edx), %eax <=== ...direct access here
orl $1, %eax
movb %al, (%edx)
movl a__var, %edx <=== useless reloading of a__var
movzbl (%edx), %eax
orl $2, %eax
movb %al, (%edx)
ret
If the variable is declared in the same compilation unit, we get:
_ada_u:
movzbl 1000, %eax
orl $1, %eax
movb %al, 1000
movzbl 1000, %eax
orl $2, %eax
movb %al, 1000
ret
We should probably get the same code in both cases.
--
Summary: Suboptimal code generation for volatile access
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: ada
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: sam at gcc dot gnu dot org
GCC host triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37604
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug ada/37604] Suboptimal code generation for volatile access
2008-09-20 20:15 [Bug ada/37604] New: Suboptimal code generation for volatile access sam at gcc dot gnu dot org
@ 2008-09-21 12:21 ` rguenth at gcc dot gnu dot org
2008-09-21 12:25 ` sam at gcc dot gnu dot org
1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-09-21 12:21 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from rguenth at gcc dot gnu dot org 2008-09-21 12:20 -------
We don't try to optimize volatile accesses.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37604
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug ada/37604] Suboptimal code generation for volatile access
2008-09-20 20:15 [Bug ada/37604] New: Suboptimal code generation for volatile access sam at gcc dot gnu dot org
2008-09-21 12:21 ` [Bug ada/37604] " rguenth at gcc dot gnu dot org
@ 2008-09-21 12:25 ` sam at gcc dot gnu dot org
1 sibling, 0 replies; 3+ messages in thread
From: sam at gcc dot gnu dot org @ 2008-09-21 12:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from sam at gcc dot gnu dot org 2008-09-21 12:23 -------
Well, in the second example I give (variable declared in the same compilation
unit), the access is optimized. What I don't get is the difference between both
cases, while the compiler does have the same information at its disposal.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37604
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-09-21 12:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-20 20:15 [Bug ada/37604] New: Suboptimal code generation for volatile access sam at gcc dot gnu dot org
2008-09-21 12:21 ` [Bug ada/37604] " rguenth at gcc dot gnu dot org
2008-09-21 12:25 ` sam 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).