linux/arch/mips
Maciej W. Rozycki 84aa85108b MIPS: Rewrite `csum_tcpudp_nofold' in plain C
Recent commit 198688edbf ("MIPS: Fix inline asm input/output type
mismatch in checksum.h used with Clang") introduced a code size and
performance regression with 64-bit code emitted for `csum_tcpudp_nofold'
by GCC, caused by a redundant truncation operation produced due to a
data type change made to the variable associated with the inline
assembly's output operand.

The intent previously expressed here with operands and constraints for
optimal code was to have the output operand share a register with one
inputs, both of a different integer type each.  This is perfectly valid
with the MIPS psABI where a register can hold integer data of different
types and the assembly code used here makes data stored in the output
register match the data type used with the output operand, however it
has turned out impossible to express this arrangement in source code
such as to satisfy LLVM, apparently due to the compiler's internal
limitations.

There is nothing peculiar about the inline assembly `csum_tcpudp_nofold'
includes however, though it does choose assembly instructions carefully.

Rewrite this piece of assembly in plain C then, using corresponding C
language operations, making GCC produce the same assembly instructions,
possibly shuffled, in the general case and sometimes actually fewer of
them where an input is constant, because the compiler does not have to
reload it to a register (operand constraints could be adjusted for that,
but the plain C approach is cleaner anyway).

Example code size changes are as follows, for a 32-bit configuration:

      text       data        bss      total filename
   5920480    1347236     126592    7394308 vmlinux-old
   5920480    1347236     126592    7394308 vmlinux-now
   5919728    1347236     126592    7393556 vmlinux-c

and for a 64-bit configuration:

      text       data        bss      total filename
   6024112    1790828     225728    8040668 vmlinux-old
   6024128    1790828     225728    8040684 vmlinux-now
   6023760    1790828     225728    8040316 vmlinux-c

respectively, where "old" is with the commit referred reverted, "now" is
with no change, and "c" is with this change applied.

Signed-off-by: Maciej W. Rozycki <macro@orcam.me.uk>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
2022-05-23 11:29:59 +02:00
..
alchemy MIPS: fix typos in comments 2022-05-04 22:22:59 +02:00
ar7 mips: ar7: convert to CONFIG_COMMON_CLK 2021-06-08 17:00:09 +02:00
ath25 MIPS: ath25: Constify static irq_domain_ops 2022-02-22 09:39:03 +01:00
ath79 MIPS: Remove redundant definitions of device_tree_init() 2022-03-14 15:09:02 +01:00
bcm47xx MIPS: BCM47XX: Add support for Netgear WN2500RP v1 & v2 2022-01-09 15:41:50 +01:00
bcm63xx linux-watchdog 5.17-rc1 tag 2022-01-17 08:07:57 +02:00
bmips MIPS: bmips: Remove obsolete DMA mapping support 2022-01-11 11:55:41 +01:00
boot MIPS: Ingenic: Refresh device tree for Ingenic SoCs and boards. 2022-05-23 11:10:01 +02:00
cavium-octeon MIPS: fix typos in comments 2022-05-04 22:22:59 +02:00
cobalt
configs MIPS: Ingenic: Refresh defconfig for CU1000-Neo and CU1830-Neo. 2022-05-23 11:10:13 +02:00
crypto MIPS: crypto: Fix CRC32 code 2022-04-01 10:19:03 +02:00
dec MIPS: fix typos in comments 2022-05-04 22:22:59 +02:00
fw MIPS: fix typos in comments 2022-05-04 22:22:59 +02:00
generic MIPS: new Kconfig option ZBOOT_LOAD_ADDRESS 2022-01-02 14:17:30 +01:00
include MIPS: Rewrite `csum_tcpudp_nofold' in plain C 2022-05-23 11:29:59 +02:00
ingenic MIPS: Kconfig: ingenic: Ensure MACH_INGENIC_GENERIC selects all SoCs 2021-06-01 11:44:47 +02:00
jazz MIPS: fix typos in comments 2022-05-04 22:22:59 +02:00
kernel mips: setup: use strscpy to replace strlcpy 2022-05-23 11:29:48 +02:00
kvm MIPS: fix typos in comments 2022-05-04 22:22:59 +02:00
lantiq MIPS: lantiq: check the return value of kzalloc() 2022-03-30 20:25:48 +02:00
lib MIPS: Only use current_stack_pointer on GCC 2022-03-14 15:02:53 +01:00
loongson2ef MIPS: Loongson{2ef,64}: Wrap -mno-branch-likely with cc-option 2022-02-07 18:30:12 +01:00
loongson32 MIPS: loongson32: Kconfig: Remove extra space 2022-05-23 11:08:45 +02:00
loongson64 MIPS: Fix build error for loongson64 and sgi-ip27 2022-03-24 09:45:15 +01:00
math-emu
mm MIPS: Use NOKPROBE_SYMBOL() instead of __kprobes annotation 2022-05-12 18:00:51 +02:00
mti-malta MIPS: Remove redundant definitions of device_tree_init() 2022-03-14 15:09:02 +01:00
n64
net MIPS: fix typos in comments 2022-05-04 22:22:59 +02:00
pci MIPS: Octeon: fix typo in comment 2022-05-23 11:08:56 +02:00
pic32 MIPS: fix typos in comments 2022-05-04 22:22:59 +02:00
power
ralink Staging driver update for 5.18-rc1 2022-03-28 12:50:50 -07:00
rb532 MIPS: rb532: move GPIOD definition into C-files 2022-03-30 20:26:26 +02:00
sgi-ip22 mips: ip22: Reword PANICED to PANICKED and remove useless header 2022-05-04 22:23:56 +02:00
sgi-ip27 MIPS: SGI-IP27: Free some unused memory 2022-04-26 15:06:00 +02:00
sgi-ip30 MIPS: SGI-IP30: Free some unused memory 2022-04-26 15:07:23 +02:00
sgi-ip32 MIPS: Allow modules to set board_be_handler 2021-11-09 16:07:26 +01:00
sibyte MIPS: Sibyte: remove unnecessary return variable 2022-05-12 18:06:50 +02:00
sni MIPS: sni: Fix the build 2021-10-18 18:09:54 +02:00
tools MIPS: fix typos in comments 2022-05-04 22:22:59 +02:00
txx9 MIPS: fix typos in comments 2022-05-04 22:22:59 +02:00
vdso mips: Enable KCSAN 2022-02-07 18:31:57 +01:00
vr41xx MIPS: VR41xx: Drop redundant spinlock initialization 2022-05-12 17:56:44 +02:00
Kbuild kbuild: use more subdir- for visiting subdirectories while cleaning 2021-10-24 13:49:46 +09:00
Kbuild.platforms MIPS: Remove TX39XX support 2022-03-01 10:07:22 +01:00
Kconfig MIPS: Fix build error for loongson64 and sgi-ip27 2022-03-24 09:45:15 +01:00
Kconfig.debug tracing: Refactor TRACE_IRQFLAGS_SUPPORT in Kconfig 2021-08-16 11:37:21 -04:00
Makefile mips: Always permit to build u-boot images 2022-03-07 13:11:20 +01:00
Makefile.postlink