This is the mail archive of the gcc@gcc.gnu.org mailing 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]

common subexpression elimination no longer working for asm()?


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());
}



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]