Alpha is one of the last targets still forcing TARGET_LRA_P to false, and
reload is slated for removal (PR113932). Add a transitional -mlra option,
following the hppa pattern (r16-5534), so that -mno-lra remains available as
an escape hatch until reload is deleted.
LRA is enabled by default only on BWX targets. On non-BWX targets a QImode or
HImode pseudo that has to be spilled reaches the target's reload_in<mode> /
reload_out<mode> secondary-reload path, which LRA does not yet drive correctly
(PR117185: LRA either loops generating reload insns or passes a pseudo where
get_unaligned_address expects a MEM). BWX has real byte/word memory
instructions and does not need that path, so it is unaffected. Gating the
default on TARGET_BWX enables LRA where it is known good and leaves non-BWX on
reload until PR117185 is resolved. -mlra / -mno-lra override the default in
either direction.
The default is resolved in alpha_option_override once TARGET_BWX is final, so
it tracks -mcpu (e.g. -mcpu=ev4 selects reload, -mcpu=ev56 selects LRA) rather
than only the configured default CPU.
Tested with an alpha-linux-gnu cross (both ev4/non-BWX and --with-cpu=ev56/BWX,
--enable-checking=yes,rtl): libgcc, libgomp and libstdc++ build cleanly under
LRA, and gcc.c-torture/execute under qemu-alpha at -O0 and -O2 gives identical
results with -mlra and -mno-lra on both configurations (3380 results each, no
differences). A native ev56 bootstrap with c,c++,m2 completes and, comparing a
full make check-gcc/check-g++ at the default (LRA) against --target_board
unix/-mno-lra (reload), LRA shows no correctness regressions: gcc unexpected
failures drop from 626 to 541 and g++ from 57 to 56, with the only LRA-only
differences being debug-info-quality (gcc.dg/guality) shifts in LRA's favor.
The prerequisite middle-end fix for the BWX m2 miscompile is PR117184.
gcc/
* config/alpha/alpha.opt (mlra): New option.
* config/alpha/alpha.cc (alpha_option_override): Default alpha_lra_p
to TARGET_BWX when not set explicitly.
(alpha_use_lra_p): New function.
(TARGET_LRA_P): Define to it instead of hook_bool_void_false.
---
gcc/config/alpha/alpha.cc | 18 +++++++++++++++++-
gcc/config/alpha/alpha.opt | 4 ++++
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git ./gcc/config/alpha/alpha.cc ./gcc/config/alpha/alpha.cc
index 90e4c21dd11..a6aceb1b21b 100644
--- ./gcc/config/alpha/alpha.cc
+++ ./gcc/config/alpha/alpha.cc
@@ -209,6 +209,7 @@ static rtx alpha_emit_xfloating_compare (enum rtx_code *,
rtx, rtx);
static void alpha_handle_trap_shadows (void);
static void alpha_align_insns (void);
static void alpha_override_options_after_change (void);
+static bool alpha_use_lra_p (void);
#if TARGET_ABI_OPEN_VMS
static void alpha_write_linkage (FILE *, const char *);
@@ -585,6 +586,13 @@ alpha_option_override (void)
else if (flag_pic == 2)
target_flags &= ~MASK_SMALL_DATA;
+ /* Default to LRA on BWX targets, where it has been validated. On non-BWX
+ targets QImode and HImode reloads still rely on the reload-only secondary
+ reload path that LRA does not yet drive (PR117185), so keep those on
+ reload until that is fixed. An explicit -mlra/-mno-lra overrides this.
*/
+ if (alpha_lra_p < 0)
+ alpha_lra_p = TARGET_BWX;
+
alpha_override_options_after_change ();
/* Register variables and functions with the garbage collector. */
@@ -625,6 +633,14 @@ alpha_override_options_after_change (void)
str_align_functions = "16";
}
+/* Implement TARGET_LRA_P. */
+
+static bool
+alpha_use_lra_p (void)
+{
+ return alpha_lra_p;
+}
+
/* Returns 1 if VALUE is a mask that contains full bytes of zero or ones. */
int
@@ -10817,7 +10833,7 @@ alpha_c_mode_for_floating_type (enum tree_index ti)
#endif
#undef TARGET_LRA_P
-#define TARGET_LRA_P hook_bool_void_false
+#define TARGET_LRA_P alpha_use_lra_p
#undef TARGET_LEGITIMATE_ADDRESS_P
#define TARGET_LEGITIMATE_ADDRESS_P alpha_legitimate_address_p
diff --git ./gcc/config/alpha/alpha.opt ./gcc/config/alpha/alpha.opt
index 1c1fbbb69f1..c97c31a865d 100644
--- ./gcc/config/alpha/alpha.opt
+++ ./gcc/config/alpha/alpha.opt
@@ -136,3 +136,7 @@ Tune expected memory latency.
mtls-size=
Target RejectNegative Joined UInteger Var(alpha_tls_size) Init(32)
Specify bit size of immediate TLS offsets.
+
+mlra
+Target Var(alpha_lra_p) Init(-1) Undocumented
+Use LRA instead of reload (transitional).
--
2.54.0