[Bug c/79674] Missed optimisation when no sequence point present
etienne_lorrain at yahoo dot fr
gcc-bugzilla@gcc.gnu.org
Wed Feb 22 14:44:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79674
--- Comment #2 from etienne_lorrain at yahoo dot fr ---
Well, I did not really want to link to the store-merging optimisation in
particular, I wanted to point out that order of evaluation inside the function
call are not defined by the standard, so argument evaluation could be changed
to increase optimisation.
Here is an example without using volatile:
------>o--o<---------
static inline void parallel (int c_compliant, ...) {}
struct { unsigned char r, g, b, t; } vol_str;
int external_fct(void);
void fct1 (void)
{
vol_str.r = 1,
vol_str.g = 2,
external_fct(),
vol_str.b = 3,
vol_str.t = 0;
}
void fct2 (void)
{
parallel (vol_str.r = 1, vol_str.g = 2, external_fct(), vol_str.b = 3,
vol_str.t = 0);
}
unsigned fct_use(void) { return vol_str.r; } // do not remove, anonymous
struct!
------>o--o<---------
fct2() could write a 32 bit value and call external_fct() either before or
after, unlike fct1().
More information about the Gcc-bugs
mailing list