From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: bharata@linux.ibm.com, alex.bennee@linaro.org, david@redhat.com
Subject: [PATCH 8/8] softfloat: Use aarch64 assembly for {add,sub}{192,256}
Date: Wed, 23 Sep 2020 18:24:53 -0700 [thread overview]
Message-ID: <20200924012453.659757-9-richard.henderson@linaro.org> (raw)
In-Reply-To: <20200924012453.659757-1-richard.henderson@linaro.org>
The compiler cannot chain more than two additions together.
Use inline assembly for 3 or 4 additions.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/fpu/softfloat-macros.h | 14 ++++++++++++++
fpu/softfloat.c | 25 +++++++++++++++++++++++++
2 files changed, 39 insertions(+)
diff --git a/include/fpu/softfloat-macros.h b/include/fpu/softfloat-macros.h
index 99fa124e56..969a486fd2 100644
--- a/include/fpu/softfloat-macros.h
+++ b/include/fpu/softfloat-macros.h
@@ -442,6 +442,13 @@ static inline void
"adc %3, %0"
: "=&r"(*z0Ptr), "=&r"(*z1Ptr), "=&r"(*z2Ptr)
: "rm"(b0), "rm"(b1), "rm"(b2), "0"(a0), "1"(a1), "2"(a2));
+#elif defined(__aarch64__)
+ asm("adds %2, %x5, %x8\n\t"
+ "adcs %1, %x4, %x7\n\t"
+ "adc %0, %x3, %x6"
+ : "=&r"(*z0Ptr), "=&r"(*z1Ptr), "=&r"(*z2Ptr)
+ : "rZ"(a0), "rZ"(a1), "rZ"(a2), "rZ"(b0), "rZ"(b1), "rZ"(b2)
+ : "cc");
#else
uint64_t z0, z1, z2;
int8_t carry0, carry1;
@@ -507,6 +514,13 @@ static inline void
"sbb %3, %0"
: "=&r"(*z0Ptr), "=&r"(*z1Ptr), "=&r"(*z2Ptr)
: "rm"(b0), "rm"(b1), "rm"(b2), "0"(a0), "1"(a1), "2"(a2));
+#elif defined(__aarch64__)
+ asm("subs %2, %x5, %x8\n\t"
+ "sbcs %1, %x4, %x7\n\t"
+ "sbc %0, %x3, %x6"
+ : "=&r"(*z0Ptr), "=&r"(*z1Ptr), "=&r"(*z2Ptr)
+ : "rZ"(a0), "rZ"(a1), "rZ"(a2), "rZ"(b0), "rZ"(b1), "rZ"(b2)
+ : "cc");
#else
uint64_t z0, z1, z2;
int8_t borrow0, borrow1;
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index d8e5d90fd7..1601095d60 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -7305,6 +7305,16 @@ static void sub256(uint64_t r[4], uint64_t a[4], uint64_t b[4])
: "=&r"(r[0]), "=&r"(r[1]), "=&r"(r[2]), "=&r"(r[3])
: "rme"(b[0]), "rme"(b[1]), "rme"(b[2]), "rme"(b[3]),
"0"(a[0]), "1"(a[1]), "2"(a[2]), "3"(a[3]));
+#elif defined(__aarch64__)
+ asm("subs %[r3], %x[a3], %x[b3]\n\t"
+ "sbcs %[r2], %x[a2], %x[b2]\n\t"
+ "sbcs %[r1], %x[a1], %x[b1]\n\t"
+ "sbc %[r0], %x[a0], %x[b0]"
+ : [r0] "=&r"(r[0]), [r1] "=&r"(r[1]),
+ [r2] "=&r"(r[2]), [r3] "=&r"(r[3])
+ : [a0] "rZ"(a[0]), [a1] "rZ"(a[1]), [a2] "rZ"(a[2]), [a3] "rZ"(a[3]),
+ [b0] "rZ"(b[0]), [b1] "rZ"(b[1]), [b2] "rZ"(b[2]), [b3] "rZ"(b[3])
+ : "cc");
#else
bool borrow = false;
@@ -7330,6 +7340,13 @@ static void neg256(uint64_t a[4])
"sbb %4, %0"
: "=&r"(a[0]), "=&r"(a[1]), "=&r"(a[2]), "+rm"(a[3])
: "rme"(a[0]), "rme"(a[1]), "rme"(a[2]), "0"(0), "1"(0), "2"(0));
+#elif defined(__aarch64__)
+ asm("negs %3, %3\n\t"
+ "ngcs %2, %2\n\t"
+ "ngcs %1, %1\n\t"
+ "ngc %0, %0"
+ : "+r"(a[0]), "+r"(a[1]), "+r"(a[2]), "+r"(a[3])
+ : : "cc");
#else
a[3] = -a[3];
if (likely(a[3])) {
@@ -7364,6 +7381,14 @@ static void add256(uint64_t a[4], uint64_t b[4])
"adc %4, %0"
: "+r"(a[0]), "+r"(a[1]), "+r"(a[2]), "+r"(a[3])
: "rme"(b[0]), "rme"(b[1]), "rme"(b[2]), "rme"(b[3]));
+#elif defined(__aarch64__)
+ asm("adds %3, %3, %x7\n\t"
+ "adcs %2, %2, %x6\n\t"
+ "adcs %1, %1, %x5\n\t"
+ "adc %0, %0, %x4"
+ : "+r"(a[0]), "+r"(a[1]), "+r"(a[2]), "+r"(a[3])
+ : "rZ"(b[0]), "rZ"(b[1]), "rZ"(b[2]), "rZ"(b[3])
+ : "cc");
#else
bool carry = false;
--
2.25.1
next prev parent reply other threads:[~2020-09-24 1:28 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-24 1:24 [PATCH 0/8] softfloat: Implement float128_muladd Richard Henderson
2020-09-24 1:24 ` [PATCH 1/8] softfloat: Use mulu64 for mul64To128 Richard Henderson
2020-09-24 7:32 ` David Hildenbrand
2020-09-24 1:24 ` [PATCH 2/8] softfloat: Use int128.h for some operations Richard Henderson
2020-09-24 7:35 ` David Hildenbrand
2020-09-24 1:24 ` [PATCH 3/8] softfloat: Tidy a * b + inf return Richard Henderson
2020-09-24 7:37 ` David Hildenbrand
2020-09-24 1:24 ` [PATCH 4/8] softfloat: Add float_cmask and constants Richard Henderson
2020-09-24 7:40 ` David Hildenbrand
2020-09-24 1:24 ` [PATCH 5/8] softfloat: Inline pick_nan_muladd into its caller Richard Henderson
2020-09-24 7:42 ` David Hildenbrand
2020-09-24 1:24 ` [PATCH 6/8] softfloat: Implement float128_muladd Richard Henderson
2020-09-24 7:56 ` David Hildenbrand
2020-09-24 13:30 ` Richard Henderson
2020-09-25 9:17 ` David Hildenbrand
2020-09-24 1:24 ` [PATCH 7/8] softfloat: Use x86_64 assembly for {add,sub}{192,256} Richard Henderson
2020-09-24 1:24 ` Richard Henderson [this message]
2020-09-24 8:00 ` [PATCH 0/8] softfloat: Implement float128_muladd David Hildenbrand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200924012453.659757-9-richard.henderson@linaro.org \
--to=richard.henderson@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=bharata@linux.ibm.com \
--cc=david@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).