[AArch64] PR target/78362: Make sure to only take REGNO of a register
authorKyrylo Tkachov <kyrylo.tkachov@arm.com>
Wed, 30 Nov 2016 12:18:47 +0000 (12:18 +0000)
committerKyrylo Tkachov <ktkachov@gcc.gnu.org>
Wed, 30 Nov 2016 12:18:47 +0000 (12:18 +0000)
PR target/78362
* config/aarch64/aarch64.md (add<mode>3): 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.

From-SVN: r243011

gcc/ChangeLog
gcc/config/aarch64/aarch64.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr78362.c [new file with mode: 0644]

index 4f3c773..8fd098b 100644 (file)
@@ -1,3 +1,10 @@
+2016-11-30  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
+
+       PR target/78362
+       * config/aarch64/aarch64.md (add<mode>3): 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  <claziss@synopsys.com>
            Andrew Burgess  <andrew.burgess@embecosm.com>
 
index 26982f6..bc6d8a2 100644 (file)
              (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>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>mode, operands[2]);
 })
 
index e89bca5..d2d80d2 100644 (file)
@@ -1,3 +1,8 @@
+2016-11-30  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
+
+       PR target/78362
+       * gcc.c-torture/compile/pr78362.c: New test.
+
 2016-11-30  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * 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 (file)
index 0000000..66eea7d
--- /dev/null
@@ -0,0 +1,11 @@
+/* PR target/78362.  */
+
+long a;
+
+void
+foo (void)
+{
+  for (;; a--)
+    if ((int) a)
+      break;
+}