Skip to content

Commit 0650853

Browse files
npitrearndb
authored andcommitted
ARM: div64: improve __arch_xprod_64()
Let's use the same criteria for overflow handling necessity as the generic code. Signed-off-by: Nicolas Pitre <npitre@baylibre.com> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
1 parent 00a31dd commit 0650853

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

arch/arm/include/asm/div64.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,16 @@ static inline uint64_t __arch_xprod_64(uint64_t m, uint64_t n, bool bias)
5656
{
5757
unsigned long long res;
5858
register unsigned int tmp asm("ip") = 0;
59+
bool no_ovf = __builtin_constant_p(m) &&
60+
((m >> 32) + (m & 0xffffffff) < 0x100000000);
5961

6062
if (!bias) {
6163
asm ( "umull %Q0, %R0, %Q1, %Q2\n\t"
6264
"mov %Q0, #0"
6365
: "=&r" (res)
6466
: "r" (m), "r" (n)
6567
: "cc");
66-
} else if (!(m & ((1ULL << 63) | (1ULL << 31)))) {
68+
} else if (no_ovf) {
6769
res = m;
6870
asm ( "umlal %Q0, %R0, %Q1, %Q2\n\t"
6971
"mov %Q0, #0"
@@ -80,7 +82,7 @@ static inline uint64_t __arch_xprod_64(uint64_t m, uint64_t n, bool bias)
8082
: "cc");
8183
}
8284

83-
if (!(m & ((1ULL << 63) | (1ULL << 31)))) {
85+
if (no_ovf) {
8486
asm ( "umlal %R0, %Q0, %R1, %Q2\n\t"
8587
"umlal %R0, %Q0, %Q1, %R2\n\t"
8688
"mov %R0, #0\n\t"

0 commit comments

Comments
 (0)