[Bug rtl-optimization/17972] const/pure functions result in bad asm
mostrows at watson dot ibm dot com
gcc-bugzilla@gcc.gnu.org
Wed Oct 13 23:11:00 GMT 2004
------- Additional Comments From mostrows at watson dot ibm dot com 2004-10-13 23:11 -------
Subject: Re: const/pure functions result in
bad asm
Here is simpler code that demonstrates the problem. Note, no loops
involved. Further below is compilation and objdump with and without
DBUG.
struct thread_info {
int preempt_count;
};
#ifdef BUG
static inline struct thread_info *cti(void)
__attribute__((pure));
#else
static inline struct thread_info *cti(void);
#endif
static inline struct thread_info *cti(void)
{
struct thread_info **ti;
__asm__("mr %0,13" : "=r"(ti));
return *ti;
}
int fn()
{
int ret = 0;
cti()->preempt_count++;
ret = cti()->preempt_count++;
return ret;
}
mostrows@heater:~/tools.k42/powerpc/partDeb/os$ powerpc64-linux-g++ -
c -o workqueue.o wq.C -O1
mostrows@heater:~/tools.k42/powerpc/partDeb/os$ powerpc64-linux-objdump
-d workqueue.o
workqueue.o: file format elf64-powerpc
Disassembly of section .text:
0000000000000000 <._Z2fnv>:
0: 7d aa 6b 78 mr r10,r13
4: e9 6a 00 00 ld r11,0(r10)
8: 81 2b 00 00 lwz r9,0(r11)
c: 39 29 00 01 addi r9,r9,1
10: 91 2b 00 00 stw r9,0(r11)
14: e9 6a 00 00 ld r11,0(r10)
18: 81 2b 00 00 lwz r9,0(r11)
1c: 7d 23 07 b4 extsw r3,r9
20: 39 29 00 01 addi r9,r9,1
24: 91 2b 00 00 stw r9,0(r11)
28: 4e 80 00 20 blr
2c: 00 00 00 00 .long 0x0
30: 00 09 00 00 .long 0x90000
34: 00 00 00 00 .long 0x0
mostrows@heater:~/tools.k42/powerpc/partDeb/os$ powerpc64-linux-g++ -
c -o workqueue.o wq.C -O1 -DBUG
mostrows@heater:~/tools.k42/powerpc/partDeb/os$ powerpc64-linux-objdump
-d workqueue.o
workqueue.o: file format elf64-powerpc
Disassembly of section .text:
0000000000000000 <._Z2fnv>:
0: 48 00 00 00 b 0 <._Z2fnv>
4: 00 00 00 00 .long 0x0
8: 00 09 00 00 .long 0x90000
c: 00 00 00 00 .long 0x0
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17972
More information about the Gcc-bugs
mailing list