From 509bb9b647516bbf6af77778d2ffe7e756be26df Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Tue, 9 Jan 2018 14:31:25 +0000 Subject: [PATCH] [AArch64] Reject (high (const (plus anchor offset))) The aarch64_legitimate_constant_p tests for HIGH and CONST seem to be the wrong way round: (high (const ...)) is valid rtl that could be passed in, but (const (high ...)) isn't. As it stands, we disallow anchor+offset but allow (high anchor+offset). 2018-01-09 Richard Sandiford gcc/ * config/aarch64/aarch64.c (aarch64_legitimate_constant_p): Fix order of HIGH and CONST checks. From-SVN: r256384 --- gcc/ChangeLog | 5 +++++ gcc/config/aarch64/aarch64.c | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d3c313d8329..5ffba6348bc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2018-01-09 Richard Sandiford + + * config/aarch64/aarch64.c (aarch64_legitimate_constant_p): Fix + order of HIGH and CONST checks. + 2018-01-09 Richard Sandiford * tree-vect-stmts.c (permute_vec_elements): Create a fresh variable diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 03a92b6d695..e129362ef66 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -10449,6 +10449,9 @@ aarch64_legitimate_constant_p (machine_mode mode, rtx x) if (CONST_WIDE_INT_P (x)) return false; + if (GET_CODE (x) == HIGH) + x = XEXP (x, 0); + /* Do not allow const (plus (anchor_symbol, const_int)). */ if (GET_CODE (x) == CONST) { @@ -10460,9 +10463,6 @@ aarch64_legitimate_constant_p (machine_mode mode, rtx x) return false; } - if (GET_CODE (x) == HIGH) - x = XEXP (x, 0); - /* Treat symbols as constants. Avoid TLS symbols as they are complex, so spilling them is better than rematerialization. */ if (SYMBOL_REF_P (x) && !SYMBOL_REF_TLS_MODEL (x)) -- 2.30.2