Skip to content

Commit 65b4dce

Browse files
committed
target/hexagon: Use mulu64 for int128_mul_6464
No need to open-code 64x64->128-bit multiplication. Reviewed-by: Brian Cain <[email protected]> Signed-off-by: Richard Henderson <[email protected]>
1 parent 8429306 commit 65b4dce

File tree

1 file changed

+3
-29
lines changed

1 file changed

+3
-29
lines changed

target/hexagon/fma_emu.c

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -82,38 +82,12 @@ int32_t float32_getexp(float32 f32)
8282
return -1;
8383
}
8484

85-
static uint32_t int128_getw0(Int128 x)
86-
{
87-
return int128_getlo(x);
88-
}
89-
90-
static uint32_t int128_getw1(Int128 x)
91-
{
92-
return int128_getlo(x) >> 32;
93-
}
94-
9585
static Int128 int128_mul_6464(uint64_t ai, uint64_t bi)
9686
{
97-
Int128 a, b;
98-
uint64_t pp0, pp1a, pp1b, pp1s, pp2;
99-
100-
a = int128_make64(ai);
101-
b = int128_make64(bi);
102-
pp0 = (uint64_t)int128_getw0(a) * (uint64_t)int128_getw0(b);
103-
pp1a = (uint64_t)int128_getw1(a) * (uint64_t)int128_getw0(b);
104-
pp1b = (uint64_t)int128_getw1(b) * (uint64_t)int128_getw0(a);
105-
pp2 = (uint64_t)int128_getw1(a) * (uint64_t)int128_getw1(b);
106-
107-
pp1s = pp1a + pp1b;
108-
if ((pp1s < pp1a) || (pp1s < pp1b)) {
109-
pp2 += (1ULL << 32);
110-
}
111-
uint64_t ret_low = pp0 + (pp1s << 32);
112-
if ((ret_low < pp0) || (ret_low < (pp1s << 32))) {
113-
pp2 += 1;
114-
}
87+
uint64_t l, h;
11588

116-
return int128_make128(ret_low, pp2 + (pp1s >> 32));
89+
mulu64(&l, &h, ai, bi);
90+
return int128_make128(l, h);
11791
}
11892

11993
static Int128 int128_sub_borrow(Int128 a, Int128 b, int borrow)

0 commit comments

Comments
 (0)