This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: O2 Agressive Optimisation by GCC
- From: Allan Sandfeld Jensen <linux at carewolf dot com>
- To: gcc at gcc dot gnu dot org
- Cc: Umesh Kalappa <umesh dot kalappa0 at gmail dot com>
- Date: Mon, 23 Jul 2018 01:12:10 +0200
- Subject: Re: O2 Agressive Optimisation by GCC
- References: <CAGfacvTvkR6d+dqG0Et04gxqcz9JcH3JV1vi8S=WbfJbOnv3JA@mail.gmail.com> <3072279.sIWBeCJxY3@twilight> <CAGfacvSkPSR7PNk5p5AQ81=0Lh=6WpQReFYE0DD8qM+bwGs1xQ@mail.gmail.com>
On Sonntag, 22. Juli 2018 17:01:29 CEST Umesh Kalappa wrote:
> Allan ,
>
> >>he might as well go traditional
>
> you mean using the locks ?
>
No I am meant relying on undefined behavior. In your case I would recommend
using modern atomics, which is defined behavior, and modern and fast. I was
just reminded of all the nasty and theoretically wrong ways we used to do
stuff like that 20 years ago to implement fallback locks. For instance using -
O0, asm-declarations, relying on non-inlined functions calls as memory-
barriers, etc. All stuff that "worked", but relied on various degrees of
undefined behavior.
Still if you are curious, it might be fun playing with stuff like that, and
try to figure for yourself why it works, just remember it is undefined
behavior and therefore not recommended.
'Allan