[llvm-commits] [compiler-rt] r74756 - in /compiler-rt/trunk/lib: i386/ashldi3.S i386/ashrdi3.S i386/lshrdi3.S negdi2.c negti2.c umodsi3.c
Eli Friedman
eli.friedman at gmail.com
Thu Jul 2 19:26:38 PDT 2009
Author: efriedma
Date: Thu Jul 2 21:26:38 2009
New Revision: 74756
URL: http://llvm.org/viewvc/llvm-project?rev=74756&view=rev
Log:
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).
Modified:
compiler-rt/trunk/lib/i386/ashldi3.S
compiler-rt/trunk/lib/i386/ashrdi3.S
compiler-rt/trunk/lib/i386/lshrdi3.S
compiler-rt/trunk/lib/negdi2.c
compiler-rt/trunk/lib/negti2.c
compiler-rt/trunk/lib/umodsi3.c
Modified: compiler-rt/trunk/lib/i386/ashldi3.S
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/i386/ashldi3.S?rev=74756&r1=74755&r2=74756&view=diff
==============================================================================
--- compiler-rt/trunk/lib/i386/ashldi3.S (original)
+++ compiler-rt/trunk/lib/i386/ashldi3.S Thu Jul 2 21:26:38 2009
@@ -40,23 +40,14 @@
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
Modified: compiler-rt/trunk/lib/i386/ashrdi3.S
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/i386/ashrdi3.S?rev=74756&r1=74755&r2=74756&view=diff
==============================================================================
--- compiler-rt/trunk/lib/i386/ashrdi3.S (original)
+++ compiler-rt/trunk/lib/i386/ashrdi3.S Thu Jul 2 21:26:38 2009
@@ -52,21 +52,13 @@
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
Modified: compiler-rt/trunk/lib/i386/lshrdi3.S
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/i386/lshrdi3.S?rev=74756&r1=74755&r2=74756&view=diff
==============================================================================
--- compiler-rt/trunk/lib/i386/lshrdi3.S (original)
+++ compiler-rt/trunk/lib/i386/lshrdi3.S Thu Jul 2 21:26:38 2009
@@ -42,21 +42,13 @@
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
Modified: compiler-rt/trunk/lib/negdi2.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/negdi2.c?rev=74756&r1=74755&r2=74756&view=diff
==============================================================================
--- compiler-rt/trunk/lib/negdi2.c (original)
+++ compiler-rt/trunk/lib/negdi2.c Thu Jul 2 21:26:38 2009
@@ -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;
}
Modified: compiler-rt/trunk/lib/negti2.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/negti2.c?rev=74756&r1=74755&r2=74756&view=diff
==============================================================================
--- compiler-rt/trunk/lib/negti2.c (original)
+++ compiler-rt/trunk/lib/negti2.c Thu Jul 2 21:26:38 2009
@@ -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
Modified: compiler-rt/trunk/lib/umodsi3.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/umodsi3.c?rev=74756&r1=74755&r2=74756&view=diff
==============================================================================
--- compiler-rt/trunk/lib/umodsi3.c (original)
+++ compiler-rt/trunk/lib/umodsi3.c Thu Jul 2 21:26:38 2009
@@ -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;
}
More information about the llvm-commits
mailing list