diff mbox series

[committed] MSP430: Define NO_FUNCTION_CSE

Message ID 20200721164527.lytu6e5ypi6lz6e7@jozef-acer-manjaro
State New
Headers show
Series [committed] MSP430: Define NO_FUNCTION_CSE | expand

Commit Message

Jozef Lawrynowicz July 21, 2020, 4:45 p.m. UTC
Calling a constant function address costs the same number of clock
cycles as calling an address stored in a register. However, in terms of
instruction length, calling a constant address is more expensive.

Set NO_FUNCTION_CSE to true, only when optimizing for speed.

Committed the attached patch as obvious. Successfully regtested on trunk
for msp430-elf.
From 111afded7fdf46ce14972aa8a72c26c9a180ab70 Mon Sep 17 00:00:00 2001
From: Jozef Lawrynowicz <jozef.l@mittosystems.com>
Date: Tue, 21 Jul 2020 17:24:03 +0100
Subject: [PATCH] MSP430: Define NO_FUNCTION_CSE

Calling a constant function address costs the same number of clock
cycles as calling an address stored in a register. However, in terms of
instruction length, calling a constant address is more expensive.

Set NO_FUNCTION_CSE to true, only when optimizing for speed.

gcc/ChangeLog:

	* config/msp430/msp430.h (NO_FUNCTION_CSE): Set to true at -O2 and
	above.
---
 gcc/config/msp430/msp430.h | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/gcc/config/msp430/msp430.h b/gcc/config/msp430/msp430.h
index f198981ad9e..e97e833a10c 100644
--- a/gcc/config/msp430/msp430.h
+++ b/gcc/config/msp430/msp430.h
@@ -257,6 +257,11 @@  extern const char *msp430_get_linker_devices_include_path (int, const char **);
   msp430_return_addr_rtx (COUNT)
 
 #define SLOW_BYTE_ACCESS		0
+
+/* Calling a constant function address costs the same number of clock
+   cycles as calling an address stored in a register. However, in terms of
+   instruction length, calling a constant address is more expensive.  */
+#define NO_FUNCTION_CSE (optimize >= 2 && !optimize_size)
 
 
 /* Register Usage */