arc.md (*loadqi_update): Use new 'any_mem_operand' and fix RTL pattern to include...
authorAndrew Burgess <andrew.burgess@embecosm.com>
Sat, 19 Dec 2015 19:22:51 +0000 (19:22 +0000)
committerJoern Rennecke <amylaar@gcc.gnu.org>
Sat, 19 Dec 2015 19:22:51 +0000 (19:22 +0000)
gcc:

        2015-12-19  Andrew Burgess  <andrew.burgess@embecosm.com>

        * config/arc/arc.md (*loadqi_update): Use new 'any_mem_operand'
        and fix RTL pattern to include the plus.
        (*load_zeroextendqisi_update): Likewise.
        (*load_signextendqisi_update): Likewise.
        (*loadhi_update): Likewise.
        (*load_zeroextendhisi_update): Likewise.
        (*load_signextendhisi_update): Likewise.
        (*loadsi_update): Likewise.
        (*loadsf_update): Likewise.
        * config/arc/predicates.md (load_update_operand): Delete.
        (any_mem_operand): New predicate.

gcc/testsuite:

        2015-12-19  Andrew Burgess  <andrew.burgess@embecosm.com>

        * gcc.target/arc/load-update.c: New file.

From-SVN: r231849

gcc/ChangeLog
gcc/config/arc/arc.md
gcc/config/arc/predicates.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/arc/load-update.c [new file with mode: 0644]

index d024128977ad06417097ad7e4b95f20b3b2dfb95..b0ec3c7f7a9134b1f6bf0c9a1d73831896dfc186 100644 (file)
@@ -1,3 +1,17 @@
+2015-12-19  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * config/arc/arc.md (*loadqi_update): Use new 'any_mem_operand'
+       and fix RTL pattern to include the plus.
+       (*load_zeroextendqisi_update): Likewise.
+       (*load_signextendqisi_update): Likewise.
+       (*loadhi_update): Likewise.
+       (*load_zeroextendhisi_update): Likewise.
+       (*load_signextendhisi_update): Likewise.
+       (*loadsi_update): Likewise.
+       (*loadsf_update): Likewise.
+       * config/arc/predicates.md (load_update_operand): Delete.
+       (any_mem_operand): New predicate.
+
 2015-12-19  Sujoy Saraswati  <sujoy.saraswati@hpe.com>
 
        PR tree-optimization/61441
index ac181a98895cbb27dfae3ad094351dbd94302e1b..7ca4431f1a419c85bb2bb10ee97732b1a6c98d1f 100644 (file)
 ;; Note: loadqi_update has no 16-bit variant
 (define_insn "*loadqi_update"
   [(set (match_operand:QI 3 "dest_reg_operand" "=r,r")
-       (match_operator:QI 4 "load_update_operand"
-        [(match_operand:SI 1 "register_operand" "0,0")
-         (match_operand:SI 2 "nonmemory_operand" "rI,Cal")]))
+        (match_operator:QI 4 "any_mem_operand"
+         [(plus:SI (match_operand:SI 1 "register_operand" "0,0")
+                   (match_operand:SI 2 "nonmemory_operand" "rI,Cal"))]))
    (set (match_operand:SI 0 "dest_reg_operand" "=r,r")
        (plus:SI (match_dup 1) (match_dup 2)))]
   ""
 
 (define_insn "*load_zeroextendqisi_update"
   [(set (match_operand:SI 3 "dest_reg_operand" "=r,r")
-       (zero_extend:SI (match_operator:QI 4 "load_update_operand"
-                        [(match_operand:SI 1 "register_operand" "0,0")
-                         (match_operand:SI 2 "nonmemory_operand" "rI,Cal")])))
+       (zero_extend:SI (match_operator:QI 4 "any_mem_operand"
+                        [(plus:SI (match_operand:SI 1 "register_operand" "0,0")
+                                  (match_operand:SI 2 "nonmemory_operand" "rI,Cal"))])))
    (set (match_operand:SI 0 "dest_reg_operand" "=r,r")
        (plus:SI (match_dup 1) (match_dup 2)))]
   ""
 
 (define_insn "*load_signextendqisi_update"
   [(set (match_operand:SI 3 "dest_reg_operand" "=r,r")
-       (sign_extend:SI (match_operator:QI 4 "load_update_operand"
-                        [(match_operand:SI 1 "register_operand" "0,0")
-                         (match_operand:SI 2 "nonmemory_operand" "rI,Cal")])))
+       (sign_extend:SI (match_operator:QI 4 "any_mem_operand"
+                        [(plus:SI (match_operand:SI 1 "register_operand" "0,0")
+                                  (match_operand:SI 2 "nonmemory_operand" "rI,Cal"))])))
    (set (match_operand:SI 0 "dest_reg_operand" "=r,r")
        (plus:SI (match_dup 1) (match_dup 2)))]
   ""
 ;; Note: no 16-bit variant for this pattern
 (define_insn "*loadhi_update"
   [(set (match_operand:HI 3 "dest_reg_operand" "=r,r")
-       (match_operator:HI 4 "load_update_operand"
-        [(match_operand:SI 1 "register_operand" "0,0")
-         (match_operand:SI 2 "nonmemory_operand" "rI,Cal")]))
+       (match_operator:HI 4 "any_mem_operand"
+        [(plus:SI (match_operand:SI 1 "register_operand" "0,0")
+                  (match_operand:SI 2 "nonmemory_operand" "rI,Cal"))]))
    (set (match_operand:SI 0 "dest_reg_operand" "=w,w")
        (plus:SI (match_dup 1) (match_dup 2)))]
   ""
 
 (define_insn "*load_zeroextendhisi_update"
   [(set (match_operand:SI 3 "dest_reg_operand" "=r,r")
-       (zero_extend:SI (match_operator:HI 4 "load_update_operand"
-                        [(match_operand:SI 1 "register_operand" "0,0")
-                         (match_operand:SI 2 "nonmemory_operand" "rI,Cal")])))
+       (zero_extend:SI (match_operator:HI 4 "any_mem_operand"
+                        [(plus:SI (match_operand:SI 1 "register_operand" "0,0")
+                                  (match_operand:SI 2 "nonmemory_operand" "rI,Cal"))])))
    (set (match_operand:SI 0 "dest_reg_operand" "=r,r")
        (plus:SI (match_dup 1) (match_dup 2)))]
   ""
 ;; Note: no 16-bit variant for this instruction
 (define_insn "*load_signextendhisi_update"
   [(set (match_operand:SI 3 "dest_reg_operand" "=r,r")
-       (sign_extend:SI (match_operator:HI 4 "load_update_operand"
-                        [(match_operand:SI 1 "register_operand" "0,0")
-                         (match_operand:SI 2 "nonmemory_operand" "rI,Cal")])))
+       (sign_extend:SI (match_operator:HI 4 "any_mem_operand"
+                        [(plus:SI (match_operand:SI 1 "register_operand" "0,0")
+                                  (match_operand:SI 2 "nonmemory_operand" "rI,Cal"))])))
    (set (match_operand:SI 0 "dest_reg_operand" "=w,w")
        (plus:SI (match_dup 1) (match_dup 2)))]
   ""
 ;; No 16-bit variant for this instruction pattern
 (define_insn "*loadsi_update"
   [(set (match_operand:SI 3 "dest_reg_operand" "=r,r")
-       (match_operator:SI 4 "load_update_operand"
-        [(match_operand:SI 1 "register_operand" "0,0")
-         (match_operand:SI 2 "nonmemory_operand" "rI,Cal")]))
+       (match_operator:SI 4 "any_mem_operand"
+        [(plus:SI (match_operand:SI 1 "register_operand" "0,0")
+                  (match_operand:SI 2 "nonmemory_operand" "rI,Cal"))]))
    (set (match_operand:SI 0 "dest_reg_operand" "=w,w")
        (plus:SI (match_dup 1) (match_dup 2)))]
   ""
 
 (define_insn "*loadsf_update"
   [(set (match_operand:SF 3 "dest_reg_operand" "=r,r")
-       (match_operator:SF 4 "load_update_operand"
-        [(match_operand:SI 1 "register_operand" "0,0")
-         (match_operand:SI 2 "nonmemory_operand" "rI,Cal")]))
+       (match_operator:SF 4 "any_mem_operand"
+        [(plus:SI (match_operand:SI 1 "register_operand" "0,0")
+                  (match_operand:SI 2 "nonmemory_operand" "rI,Cal"))]))
    (set (match_operand:SI 0 "dest_reg_operand" "=w,w")
        (plus:SI (match_dup 1) (match_dup 2)))]
   ""
index de0735a407175e91c186232ff02185a3805a6778..268ff7ee0683a89249f5723ab0ee3ae68a536404 100644 (file)
 }
 )
 
-;; Return true if OP is valid load with update operand.
-(define_predicate "load_update_operand"
-  (match_code "mem")
-{
-  if (GET_CODE (op) != MEM
-      || GET_MODE (op) != mode)
-    return 0;
-  op = XEXP (op, 0);
-  if (GET_CODE (op) != PLUS
-      || GET_MODE (op) != Pmode
-      || !register_operand (XEXP (op, 0), Pmode)
-      || !nonmemory_operand (XEXP (op, 1), Pmode))
-    return 0;
-  return 1;
-
-}
-)
-
 ;; Return true if OP is valid store with update operand.
 (define_predicate "store_update_operand"
   (match_code "mem")
 (define_predicate "mem_noofs_operand"
   (and (match_code "mem")
        (match_code "reg" "0")))
+
+(define_predicate "any_mem_operand"
+  (match_code "mem"))
\ No newline at end of file
index 20ac322ae5da00f1e1e81b6ee2cda159fb68a735..d1ebe8d9a883f9c5e8116600c683c9ee61d788f0 100644 (file)
@@ -1,3 +1,7 @@
+2015-12-19  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * gcc.target/arc/load-update.c: New file.
+
 2015-12-18  Patrick Palka  <ppalka@gcc.gnu.org>
 
        PR c++/68978
diff --git a/gcc/testsuite/gcc.target/arc/load-update.c b/gcc/testsuite/gcc.target/arc/load-update.c
new file mode 100644 (file)
index 0000000..8299cb7
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-Os" } */
+
+/* This caused a segfault due to incorrect rtl pattern in some
+   instructions.  */
+
+int a, d;
+char *b;
+
+void fn1()
+{
+  char *e = 0;
+  for (; d; ++a)
+    {
+      char c = b [0];
+      *e++ = '.';
+      *e++ = 4;
+      *e++ = "0123456789abcdef" [c & 5];
+    }
+}