1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
Sun Studio:
foo:
sethi %hi(a),%o4
ld [%o4+%lo(a)],%o5
add %o5,1,%o5
st %o5,[%o4+%lo(a)]
sra %o5,0,%o3
sub %o3,11,%o2
retl ! Result = %o0
srlx %o2,63,%o0
IBM XLC
foo:
lwz r3,T.25.a(RTOC)
lwz r4,0(r3)
addi r0,r4,1
addi r4,r4,-10
stw r0,0(r3)
or r0,r0,r4
rlwinm r3,r0,1,31,31
bclr BO_ALWAYS,CR0_LT
GCC on ibm
foo:
lwz 9,LC..0(2)
lwz 10,0(9)
addi 10,10,1
cmpwi 7,10,10
stw 10,0(9)
crnot 30,29
mfcr 3
rlwinm 3,3,31,1
blr
GCC on intel
foo:
movl a(%rip), %eax
incl %eax
cmpl $10, %eax
movl %eax, a(%rip)
setle %al
ret
Intel:
foo:
movl $1, %ecx
movl a(%rip), %edx
xorl %eax, %eax
incl %edx
cmpl $10, %edx
movl %edx, a(%rip)
cmovle %ecx, %eax
ret
original:
bool foo()
{
const int some_const = 10 ;
return ++a <= some_const ;
}
|
bar:
sethi %hi(a),%o4
ld [%o4+%lo(a)],%o5
sra %o5,0,%o3
add %o5,1,%o5
st %o5,[%o4+%lo(a)]
sub %o3,10,%o2
retl ! Result = %o0
srlx %o2,63,%o0
bar:
lwz r3,T.25.a(RTOC)
lwz r4,0(r3)
addi r0,r4,-10
addi r5,r4,1
or r0,r4,r0
stw r5,0(r3)
rlwinm r3,r0,1,31,31
bclr BO_ALWAYS,CR0_LT
bar:
lwz 9,LC..1(2)
lwz 10,0(9)
cmpwi 7,10,9
addi 10,10,1
crnot 30,29
stw 10,0(9)
mfcr 3
rlwinm 3,3,31,1
blr
bar:
movl a(%rip), %eax
leal 1(%rax), %edx
cmpl $9, %eax
movl %edx, a(%rip)
setle %al
ret
bar:
movl $1, %esi
movl a(%rip), %ecx
xorl %eax, %eax
cmpl $10, %ecx
cmovl %esi, %eax
lea 1(%rcx), %edx
movl %edx, a(%rip)
ret
bool bar()
{
const int some_const = 10 ;
return a++ < some_const ;
} |