[Top] [All Lists]

Re: [PATCH] MIPS: Implement __multi3 for GCC7 MIPS64r6 builds

To: James Hogan <>
Subject: Re: [PATCH] MIPS: Implement __multi3 for GCC7 MIPS64r6 builds
From: Waldemar Brodkorb <>
Date: Wed, 27 Dec 2017 09:31:07 +0100
Cc: Ralf Baechle <>, Thomas Petazzoni <>, "Maciej W . Rozycki" <>, Matthew Fortune <>, Florian Fainelli <>, Waldemar Brodkorb <>,
In-reply-to: <>
List-archive: <>
List-help: <>
List-id: linux-mips <>
List-owner: <>
List-post: <>
List-software: Ecartis version 1.0.0
List-subscribe: <>
List-unsubscribe: <>
Original-recipient: rfc822;
References: <20171206085034.3869dc9d@windsurf.lan> <>
User-agent: Mutt/1.5.23 (2014-03-12)
Hi James,
James Hogan wrote,

> GCC7 is a bit too eager to generate suboptimal __multi3 calls (128bit
> multiply with 128bit result) for MIPS64r6 builds, even in code which
> doesn't explicitly use 128bit types, such as the following:
> unsigned long func(unsigned long a, unsigned long b)
> {
>       return a > (~0UL) / b;
> }
> Which GCC rearanges to:
> return (unsigned __int128)a * (unsigned __int128)b > 0xffffffff;
> Therefore implement __multi3, but only for MIPS64r6 with GCC7 as under
> normal circumstances we wouldn't expect any calls to __multi3 to be
> generated from kernel code.

I tested the patch and it works fine for me. I can build a mips64r6
kernel and run the uClibc-ng testsuite inside qemu system emulation.

It works for me with 4.9.x and 4.14.x kernels.


<Prev in Thread] Current Thread [Next in Thread>