This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
common subexpression elimination no longer working for asm()?
- From: "Jan Beulich" <JBeulich at suse dot com>
- To: <gcc at gcc dot gnu dot org>
- Date: Wed, 22 Oct 2014 16:28:52 +0100
- Subject: common subexpression elimination no longer working for asm()?
- Authentication-results: sourceware.org; auth=none
I noticed the issue with 4.9.1 (in that x86 Linux'es
this_cpu_read_stable() no longer does what the comment preceding
its definition promises), and the example below demonstrates this in
a simplified (but contrived) way. I just now verified that trunk has
the same issue; 4.8.3 still folds redundant ones as expected. Is this
known, or possibly even intended (in which case I'd be curious as to
what the reasons are, and how the functionality Linux wants can be
gained back)?
Thanks, Jan
void dummy(int, int);
extern int m, p;
static inline int read_m(void) {
int i;
asm("nop %1" : "=r" (i) : "m" (m));
return i;
}
static inline int read_p(void) {
int i;
asm("nop %P1" : "=r" (i) : "p" (&p));
return i;
}
void test(void) {
dummy(read_m(), read_m());
dummy(read_p(), read_p());
dummy(read_m(), read_m());
dummy(read_p(), read_p());
}