forked from OSchip/llvm-project
Misc compiler-rt fixes. Clarify neg implementations to show what is
actually happening. Fix mod implementation so it doesn't get optimized to a recursive call. Make x86-32 non-SSE2 shift implementation use shld/shrd instead of emulating it (the only x86 processor where the emulation might be remotely close to justifiable is the Pentium 4). llvm-svn: 74756
This commit is contained in:
parent
0e8bde5910
commit
30bd27bf7d
|
@ -40,23 +40,14 @@ ___ashldi3:
|
|||
movl 12(%esp), %ecx // Load count
|
||||
movl 8(%esp), %edx // Load high
|
||||
movl 4(%esp), %eax // Load low
|
||||
|
||||
|
||||
testl $0x20, %ecx // If count >= 32
|
||||
jnz 2f // goto 2
|
||||
testl $0x1f, %ecx // If count == 0
|
||||
jz 1f // goto 1
|
||||
|
||||
pushl %ebx
|
||||
movl %eax, %ebx // copy low
|
||||
jnz 1f // goto 1
|
||||
shldl %cl, %eax, %edx // left shift high by count
|
||||
shll %cl, %eax // left shift low by count
|
||||
shll %cl, %edx // left shift high by count
|
||||
neg %cl
|
||||
shrl %cl, %ebx // right shift low by 32 - count
|
||||
orl %ebx, %edx // or the result into the high word
|
||||
popl %ebx
|
||||
1: ret
|
||||
|
||||
2: movl %eax, %edx // Move low to high
|
||||
ret
|
||||
|
||||
1: movl %eax, %edx // Move low to high
|
||||
xorl %eax, %eax // clear low
|
||||
shll %cl, %edx // shift high by count - 32
|
||||
ret
|
||||
|
|
|
@ -52,21 +52,13 @@ ___ashrdi3:
|
|||
movl 4(%esp), %eax // Load low
|
||||
|
||||
testl $0x20, %ecx // If count >= 32
|
||||
jnz 2f // goto 2
|
||||
testl $0x1f, %ecx // If count == 0
|
||||
jz 1f // goto 1
|
||||
|
||||
pushl %ebx
|
||||
movl %edx, %ebx // copy high
|
||||
shrl %cl, %eax // right shift low by count
|
||||
jnz 1f // goto 1
|
||||
|
||||
shrdl %cl, %edx, %eax // right shift low by count
|
||||
sarl %cl, %edx // right shift high by count
|
||||
neg %cl
|
||||
shll %cl, %ebx // left shift high by 32 - count
|
||||
orl %ebx, %eax // or the result into the low word
|
||||
popl %ebx
|
||||
1: ret
|
||||
ret
|
||||
|
||||
2: movl %edx, %eax // Move high to low
|
||||
1: movl %edx, %eax // Move high to low
|
||||
sarl $31, %edx // clear high
|
||||
sarl %cl, %eax // shift low by count - 32
|
||||
ret
|
||||
|
|
|
@ -42,21 +42,13 @@ ___lshrdi3:
|
|||
movl 4(%esp), %eax // Load low
|
||||
|
||||
testl $0x20, %ecx // If count >= 32
|
||||
jnz 2f // goto 2
|
||||
testl $0x1f, %ecx // If count == 0
|
||||
jz 1f // goto 1
|
||||
|
||||
pushl %ebx
|
||||
movl %edx, %ebx // copy high
|
||||
shrl %cl, %eax // right shift low by count
|
||||
jnz 1f // goto 1
|
||||
|
||||
shrdl %cl, %edx, %eax // right shift low by count
|
||||
shrl %cl, %edx // right shift high by count
|
||||
neg %cl
|
||||
shll %cl, %ebx // left shift high by 32 - count
|
||||
orl %ebx, %eax // or the result into the low word
|
||||
popl %ebx
|
||||
1: ret
|
||||
ret
|
||||
|
||||
2: movl %edx, %eax // Move high to low
|
||||
1: movl %edx, %eax // Move high to low
|
||||
xorl %edx, %edx // clear high
|
||||
shrl %cl, %eax // shift low by count - 32
|
||||
ret
|
||||
|
|
|
@ -18,5 +18,7 @@
|
|||
di_int
|
||||
__negdi2(di_int a)
|
||||
{
|
||||
return ~a + 1;
|
||||
// Note: this routine is here for API compatibility; any sane compiler
|
||||
// should expand it inline.
|
||||
return -a;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,9 @@
|
|||
ti_int
|
||||
__negti2(ti_int a)
|
||||
{
|
||||
return ~a + 1;
|
||||
// Note: this routine is here for API compatibility; any sane compiler
|
||||
// should expand it inline.
|
||||
return -a;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -15,8 +15,10 @@
|
|||
|
||||
// Returns: a % b
|
||||
|
||||
su_int __udivsi3(su_int a, su_int b);
|
||||
|
||||
su_int
|
||||
__umodsi3(su_int a, su_int b)
|
||||
{
|
||||
return a - (a / b) * b;
|
||||
return a - __udivsi3(a, b) * b;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue