Re: Correct way to express to the compiler "this does not get clobbered"?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Segher Boessenkool <segher@xxxxxxxxxxxxxxxxxxx> writes:

> On Fri, Dec 04, 2020 at 07:16:45PM +0100, Andrea Corallo via Gcc-help wrote:
>> Segher Boessenkool <segher@xxxxxxxxxxxxxxxxxxx> writes:
>> 
>> > On Fri, Dec 04, 2020 at 10:52:17AM +0100, Andrea Corallo via Gcc-help wrote:
>> >> stefan@xxxxxxxxx writes:
>> >> I might open a bug but my understanding is that const is generally
>> >> not used for optimizations.  Am I wrong?
>> >
>> > extern const int x = 42;
>> > int f(void) { return x; }
>> >
>> > The code generated for f does not load the value for x from memory: it
>> > returns 42 always.
>
>> Are you suggesting we should treat this as a bug?
>
> Huh?

Sorry for the miscommunication, with "this" I meant the code of the
original question of this thread.

> No, I am just saying that const *is* used for optimisation, with a
> dumb simple example.  Remove const from this code and you get different
> generated machine code (that does load x from memory always).
>
> If you think you have found a missing optimisation, please make a
> self-contained demonstrator for that, and a file a PR?

All righ I'll do it.

  Andrea



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux