summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Canon <scanon@apple.com>2012-06-22 14:44:13 +0000
committerStephen Canon <scanon@apple.com>2012-06-22 14:44:13 +0000
commitc3b81119a7ac9e3c44ae4666b977d8e2c65c1c5a (patch)
treece4f1d8bac3e5f724fa406c87854f441c3eca129
parent2f42bb03b7469470ff7fa51462a93c1435f73b2c (diff)
downloadbcm5719-llvm-c3b81119a7ac9e3c44ae4666b977d8e2c65c1c5a.tar.gz
bcm5719-llvm-c3b81119a7ac9e3c44ae4666b977d8e2c65c1c5a.zip
Allow divsi3 to take advantage of a hardware unsigned divide when it is available, by replacing an explicit call to udivsi3 with the divide operator. Patch by Sébastien Bourdeauducq.
llvm-svn: 158996
-rw-r--r--compiler-rt/lib/divsi3.c8
-rw-r--r--compiler-rt/lib/udivsi3.c1
2 files changed, 8 insertions, 1 deletions
diff --git a/compiler-rt/lib/divsi3.c b/compiler-rt/lib/divsi3.c
index 0d81cb80c37..44573db37d5 100644
--- a/compiler-rt/lib/divsi3.c
+++ b/compiler-rt/lib/divsi3.c
@@ -29,5 +29,11 @@ __divsi3(si_int a, si_int b)
a = (a ^ s_a) - s_a; /* negate if s_a == -1 */
b = (b ^ s_b) - s_b; /* negate if s_b == -1 */
s_a ^= s_b; /* sign of quotient */
- return (__udivsi3(a, b) ^ s_a) - s_a; /* negate if s_a == -1 */
+ /*
+ * On CPUs without unsigned hardware division support,
+ * this calls __udivsi3 (notice the cast to su_int).
+ * On CPUs with unsigned hardware division support,
+ * this uses the unsigned division instruction.
+ */
+ return ((su_int)a/(su_int)b ^ s_a) - s_a; /* negate if s_a == -1 */
}
diff --git a/compiler-rt/lib/udivsi3.c b/compiler-rt/lib/udivsi3.c
index 39ef48bea65..ba011220bb4 100644
--- a/compiler-rt/lib/udivsi3.c
+++ b/compiler-rt/lib/udivsi3.c
@@ -20,6 +20,7 @@
ARM_EABI_FNALIAS(uidiv, udivsi3);
+/* This function should not call __divsi3! */
COMPILER_RT_ABI su_int
__udivsi3(su_int n, su_int d)
{
OpenPOWER on IntegriCloud