Laurent GUERBY - Re: Why doesn't combine like volatiles? (volatile_ok again, sorry!) (original) (raw)
This is the mail archive of the gcc@gcc.gnu.orgmailing list for the GCC project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] |
- From: Laurent GUERBY
- To: Paolo Bonzini
- Cc: GCC Development , Richard Earnshaw , Robert Dewar
- Date: Mon, 28 Nov 2005 22:05:03 +0100
- Subject: Re: Why doesn't combine like volatiles? (volatile_ok again, sorry!)
- References: <SERRANO6qCvOeyYHeFu00000084@SERRANO.CAM.ARTIMI.COM> <1132674761.27134.177.camel@pc960.cambridge.arm.com> <8C2BE826-8925-45CA-AAE7-EF2F673B2819@apple.com> <1133175654.32658.11.camel@pc960.cambridge.arm.com> <438AE644.7000704@adacore.com> <438B01CF.8070803@lu.unisi.ch>
On Mon, 2005-11-28 at 14:10 +0100, Paolo Bonzini wrote:
Then, I don't know if it would be legal to optimize
struct r { unsigned int x : 7; volatile unsigned int y : 1; };
struct r my_reg;
So that my_reg.x is accessed with a non-volatile mem, and my_reg.y is accessed with a volatile one. Would such an optimization be possible within the Ada compile-time rules?
procedure P is
type T7 is mod 2**7; type T1 is mod 2; pragma Volatile (T1);
type R is record X : T7; Y : T1; end record; for R'Size use 8; for R'Alignment use 1; for R use record X at 0 range 0 .. 6; Y at 0 range 7 .. 7; end record;
Z : R; A : T7; B : T1; begin Z.X := 127; Z.Y := 1; A := Z.X; B := Z.Y; end P;
trunk gcc -O2 -S p.adb on x86-linux gives:
_ada_p: pushl %ebp movl %esp, %ebp subl $16, %esp movb $1, -1(%ebp) leave ret
My understanding is that B := Z.Y implied memory read should not be optimized away since it is a volatile read and thus an external effect, so this looks like a bug to me. (If this is not supported, GNAT should fail at compile time.)
Z.X write and read are correctly optimized away: non volatile read and write have no external effects here.
Laurent
- Follow-Ups:
- Re: Why doesn't combine like volatiles? (volatile_ok again, sorry!)
* From: Robert Dewar
- Re: Why doesn't combine like volatiles? (volatile_ok again, sorry!)
- References:
- RE: Why doesn't combine like volatiles? (volatile_ok again, sorry!)
* From: Dave Korn - RE: Why doesn't combine like volatiles? (volatile_ok again, sorry!)
* From: Richard Earnshaw - Re: Why doesn't combine like volatiles? (volatile_ok again, sorry!)
* From: Mike Stump - Re: Why doesn't combine like volatiles? (volatile_ok again, sorry!)
* From: Richard Earnshaw - Re: Why doesn't combine like volatiles? (volatile_ok again, sorry!)
* From: Robert Dewar - Re: Why doesn't combine like volatiles? (volatile_ok again, sorry!)
* From: Paolo Bonzini
- RE: Why doesn't combine like volatiles? (volatile_ok again, sorry!)
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |