Patch "MIPS: Implement __multi3 for GCC7 MIPS64r6 builds" has been added to the 4.14-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
MIPS: Implement __multi3 for GCC7 MIPS64r6 builds
to the 4.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
mips-implement-__multi3-for-gcc7-mips64r6-builds.patch
and it can be found in the queue-4.14 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
ebabcf17bcd7ce968b1631ebe08236275698f39bMon Sep 17 00:00:00 2001
From: James Hogan <[email protected]>
Date: Thu, 7 Dec 2017 07:20:46 +0000
Subject: MIPS: Implement __multi3 for GCC7 MIPS64r6 builds
From: James Hogan <[email protected]>
commit ebabcf17bcd7ce968b1631ebe08236275698f39b upstream.
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 > 0xffffffffffffffff;
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.
Patchwork: https://patchwork.linux-mips.org/patch/17890/
--- arch/mips/lib/Makefile | 3 +- arch/mips/lib/libgcc.h | 17 +++++++++++++++ arch/mips/lib/multi3.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 1 deletion(-)
arch/mips/lib/Makefile +2 -1
@@ -16,4 +16,5 @@ obj-$(CONFIG_CPU_R3000) += r3k_dump_tlb obj-$(CONFIG_CPU_TX39XX) += r3k_dump_tlb.o # libgcc-style stuff needed in the kernel -obj-y += ashldi3.o ashrdi3.o bswapsi.o bswapdi.o cmpdi2.o lshrdi3.o ucmpdi2.o +obj-y += ashldi3.o ashrdi3.o bswapsi.o bswapdi.o cmpdi2.o lshrdi3.o multi3.o \ + ucmpdi2.o
arch/mips/lib/libgcc.h +17 -0
@@ -10,10 +10,18 @@ typedef int word_type __attribute__ ((mostruct DWstruct {int high, low; }; + +struct TWstruct { +long long high, low; +};#elif defined(__LITTLE_ENDIAN)struct DWstruct {int low, high; }; + +struct TWstruct { +long long low, high; +};#else #error I feel sick.#endif
@@ -23,4 +31,13 @@ typedef union { long long ll; } DWunion; +#if defined(CONFIG_64BIT ) && defined(CONFIG_CPU_MIPSR6 ) +typedef int ti_type __attribute__((mode (TI ))); + +typedef union { +struct TWstruct s; +ti_type ti; +}TWunion ; +#endif +#endif /* __ASM_LIBGCC_H */
arch/mips/lib/multi3.c new file +54 -0
54 lines not on this page · raw message
Patches currently in stable-queue which might be from [email protected] are
queue-4.14/lib-mpi-fix-umul_ppmm-for-mips64r6.patch queue-4.14/mips-implement-__multi3-for-gcc7-mips64r6-builds.patch