From 9822b7fb4d028f9b299f39fef765b92f63dd194a Mon Sep 17 00:00:00 2001 From: ktkachov Date: Wed, 30 Nov 2016 12:18:47 +0000 Subject: [PATCH] [AArch64] PR target/78362: Make sure to only take REGNO of a register PR target/78362 * config/aarch64/aarch64.md (add3): Extract inner expression from a subreg in operands[1] and don't call REGNO on a non-reg expression when deciding to force operands[2] into a reg. * gcc.c-torture/compile/pr78362.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@243011 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 7 +++++++ gcc/config/aarch64/aarch64.md | 6 +++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.c-torture/compile/pr78362.c | 11 +++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr78362.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4f3c7738208..8fd098bc85a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2016-11-30 Kyrylo Tkachov + + PR target/78362 + * config/aarch64/aarch64.md (add3): Extract inner expression + from a subreg in operands[1] and don't call REGNO on a non-reg + expression when deciding to force operands[2] into a reg. + 2016-11-30 Claudiu Zissulescu Andrew Burgess diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md index 26982f67ee3..bc6d8a2b3c2 100644 --- a/gcc/config/aarch64/aarch64.md +++ b/gcc/config/aarch64/aarch64.md @@ -1611,11 +1611,15 @@ (match_operand:GPI 2 "aarch64_pluslong_operand" "")))] "" { + /* If operands[1] is a subreg extract the inner RTX. */ + rtx op1 = REG_P (operands[1]) ? operands[1] : SUBREG_REG (operands[1]); + /* If the constant is too large for a single instruction and isn't frame based, split off the immediate so it is available for CSE. */ if (!aarch64_plus_immediate (operands[2], mode) && can_create_pseudo_p () - && !REGNO_PTR_FRAME_P (REGNO (operands[1]))) + && (!REG_P (op1) + || !REGNO_PTR_FRAME_P (REGNO (op1)))) operands[2] = force_reg (mode, operands[2]); }) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e89bca598d6..d2d80d26e51 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-11-30 Kyrylo Tkachov + + PR target/78362 + * gcc.c-torture/compile/pr78362.c: New test. + 2016-11-30 Andrew Burgess * lib/target-supports.exp (check_effective_target_freorder): Check diff --git a/gcc/testsuite/gcc.c-torture/compile/pr78362.c b/gcc/testsuite/gcc.c-torture/compile/pr78362.c new file mode 100644 index 00000000000..66eea7d2fab --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr78362.c @@ -0,0 +1,11 @@ +/* PR target/78362. */ + +long a; + +void +foo (void) +{ + for (;; a--) + if ((int) a) + break; +} -- 2.11.4.GIT