PR66306: Fix match_dups on swapped operands.
authorAndreas Krebbel <krebbel@linux.vnet.ibm.com>
Wed, 24 Jun 2015 06:50:53 +0000 (06:50 +0000)
committerAndreas Krebbel <krebbel@gcc.gnu.org>
Wed, 24 Jun 2015 06:50:53 +0000 (06:50 +0000)
2015-06-24  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

    PR rtl-optimization/66306
    * reload.c (find_reloads): Swap the match_dup info for
    commutative operands.

2015-06-24  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

    PR rtl-optimization/66306
    * gcc.target/s390/pr66306.c: New test.

From-SVN: r224875

gcc/ChangeLog
gcc/reload.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/s390/pr66306.c [new file with mode: 0644]

index be625c5b06b32c33edec957af0f6f372573653d7..d1f82b29f53d87e2f0b40b23a93fb3b6d0e886bc 100644 (file)
@@ -1,3 +1,9 @@
+2015-06-24  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
+
+       PR rtl-optimization/66306
+       * reload.c (find_reloads): Swap the match_dup info for
+       commutative operands.
+
 2015-06-24  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
 
        * config/s390/vx-builtins.md
index 03354deb6059bfd92eed31449d7f468bd7a5b55d..1dc04bf0eb96df901aad7d043f58f4d6066c4cbe 100644 (file)
@@ -3872,6 +3872,12 @@ find_reloads (rtx_insn *insn, int replace, int ind_levels, int live_known,
       std::swap (*recog_data.operand_loc[commutative],
                 *recog_data.operand_loc[commutative + 1]);
 
+      for (i = 0; i < recog_data.n_dups; i++)
+       if (recog_data.dup_num[i] == commutative
+           || recog_data.dup_num[i] == commutative + 1)
+         *recog_data.dup_loc[i]
+           = recog_data.operand[(int) recog_data.dup_num[i]];
+
       for (i = 0; i < n_reloads; i++)
        {
          if (rld[i].opnum == commutative)
index d1431575ae8cb5e48f7a4da574f6be5e5782bc9a..8e28edc2aea76f20e095a8c3fb0b85448a6d4533 100644 (file)
@@ -1,3 +1,8 @@
+2015-06-24  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
+
+       PR rtl-optimization/66306
+       * gcc.target/s390/pr66306.c: New test.
+
 2015-06-24  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
 
        * gcc.target/s390/vector/vec-abi-1.c: Add gnu attribute check.
diff --git a/gcc/testsuite/gcc.target/s390/pr66306.c b/gcc/testsuite/gcc.target/s390/pr66306.c
new file mode 100644 (file)
index 0000000..73903cb
--- /dev/null
@@ -0,0 +1,26 @@
+/* This caused an ICE on s390x due to a reload bug handling
+   commutative constraints.  */
+
+/* { dg-do compile } */
+/* { dg-options "-O1" } */
+
+struct line_map
+{
+  unsigned start_location;
+  unsigned ordinary;
+};
+unsigned
+linemap_resolve_location (struct line_map **loc_map);
+
+unsigned
+linemap_position_for_loc_and_offset (unsigned h, unsigned loc)
+{
+  struct line_map *map = 0;
+  linemap_resolve_location (&map);
+
+  if (map->ordinary <= loc + map->start_location + map->ordinary)
+    __builtin_abort ();
+
+  if (h >= loc + map->start_location)
+    __builtin_abort ();
+}