cfgcleanup.c (old_insns_match_p): Check if used hard regs set is equal for both call...
authorDragan Mladjenovic <dmladjenovic@wavecomp.com>
Tue, 9 Jul 2019 21:20:57 +0000 (21:20 +0000)
committerJeff Law <law@gcc.gnu.org>
Tue, 9 Jul 2019 21:20:57 +0000 (15:20 -0600)
2019-07-09  Dragan Mladjenovic  <dmladjenovic@wavecomp.com>

* cfgcleanup.c (old_insns_match_p): Check if used hard regs set is equal
for both call instructions.

2019-07-09  Dragan Mladjenovic  <dmladjenovic@wavecomp.com>

* gcc.target/mips/cfgcleanup-jalr1.c: New test.
* gcc.target/mips/cfgcleanup-jalr2.c: New test.
* gcc.target/mips/cfgcleanup-jalr3.c: New test.

From-SVN: r273314

gcc/ChangeLog
gcc/cfgcleanup.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/mips/cfgcleanup-jalr1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/mips/cfgcleanup-jalr2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/mips/cfgcleanup-jalr3.c [new file with mode: 0644]

index 2061c1bb50ff9f257d283da49f8cb740e5fe1fe7..71569bfa4d6003554c2a4b99015f731cacea6d41 100644 (file)
@@ -1,3 +1,8 @@
+2019-07-09  Dragan Mladjenovic  <dmladjenovic@wavecomp.com>
+
+       * cfgcleanup.c (old_insns_match_p): Check if used hard regs set is equal
+       for both call instructions.
+
 2019-07-09  John Darrington  <john@darrington.wattle.id.au>
 
        * simplify-rtx.c (simplify_unary_operation_1): Use GET_MODE_PRECISION
index 992912ce19588cd25ca800f58f0d56ee4b5b9329..fca3a084d3759bd29854217d510946f3b3931124 100644 (file)
@@ -53,6 +53,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "dce.h"
 #include "dbgcnt.h"
 #include "rtl-iter.h"
+#include "regs.h"
 
 #define FORWARDER_BLOCK_P(BB) ((BB)->flags & BB_FORWARDER_BLOCK)
 
@@ -1224,6 +1225,14 @@ old_insns_match_p (int mode ATTRIBUTE_UNUSED, rtx_insn *i1, rtx_insn *i2)
                }
            }
        }
+
+      HARD_REG_SET i1_used, i2_used;
+
+      get_call_reg_set_usage (i1, &i1_used, call_used_reg_set);
+      get_call_reg_set_usage (i2, &i2_used, call_used_reg_set);
+
+      if (!hard_reg_set_equal_p (i1_used, i2_used))
+        return dir_none;
     }
 
   /* If both i1 and i2 are frame related, verify all the CFA notes
index 31e8a8312b5c0846bd260308bbb10c69ce7f9f75..bf7c992afb985058700df04f5d65eaa579522a54 100644 (file)
@@ -1,3 +1,9 @@
+2019-07-09  Dragan Mladjenovic  <dmladjenovic@wavecomp.com>
+
+       * gcc.target/mips/cfgcleanup-jalr1.c: New test.
+       * gcc.target/mips/cfgcleanup-jalr2.c: New test.
+       * gcc.target/mips/cfgcleanup-jalr3.c: New test.
+
 2019-07-09  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/91114
diff --git a/gcc/testsuite/gcc.target/mips/cfgcleanup-jalr1.c b/gcc/testsuite/gcc.target/mips/cfgcleanup-jalr1.c
new file mode 100644 (file)
index 0000000..24c1826
--- /dev/null
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options "-mabicalls -fpic -mno-mips16 -mno-micromips" } */
+/* { dg-skip-if "needs codesize optimization" { *-*-* } { "-O0" "-O1" "-O2" "-O3" } { "" } } */
+
+extern void foo (void*);
+
+extern void bar (void*);
+
+void
+test (void* p)
+{
+   if (!p)
+       foo(p);
+   else
+       bar(p);
+}
+
+/* { dg-final { scan-assembler-not "\\\.reloc\t1f,R_MIPS_JALR,foo" } } */
+/* { dg-final { scan-assembler-not "\\\.reloc\t1f,R_MIPS_JALR,bar" } } */
diff --git a/gcc/testsuite/gcc.target/mips/cfgcleanup-jalr2.c b/gcc/testsuite/gcc.target/mips/cfgcleanup-jalr2.c
new file mode 100644 (file)
index 0000000..9fd75c9
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-mabicalls -fpic -mno-mips16 -mno-micromips" } */
+/* { dg-additional-options "-fno-inline -fipa-ra -mcompact-branches=never" } */
+/* { dg-skip-if "needs codesize optimization" { *-*-* } { "-O0" "-O1" "-O2" "-O3" } { "" } } */
+
+static int foo (void* p) { __asm__ (""::"r"(p):"$t0"); return 0; }
+
+static int bar (void* p) { return 1; }
+
+int
+test (void* p)
+{
+  int res = !p ? foo(p) : bar(p);
+
+  register int tmp __asm__("$t0") = -1;
+  __asm__ (""::"r"(tmp));
+
+  return res;
+}
+
+/* { dg-final { scan-assembler "\\\.reloc\t1f,R_MIPS_JALR,foo" } } */
+/* { dg-final { scan-assembler "\\\.reloc\t1f,R_MIPS_JALR,bar" } } */
+/* { dg-final { scan-assembler-not "\\.set\tnomacro\n\tjalr\t\\\$25" } } */
diff --git a/gcc/testsuite/gcc.target/mips/cfgcleanup-jalr3.c b/gcc/testsuite/gcc.target/mips/cfgcleanup-jalr3.c
new file mode 100644 (file)
index 0000000..580c6ec
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-mabicalls -fpic -mno-mips16 -mno-micromips" } */
+/* { dg-additional-options "-fno-inline -fipa-ra -mcompact-branches=never" } */
+/* { dg-skip-if "needs codesize optimization" { *-*-* } { "-O0" "-O1" "-O2" "-O3" } { "" } } */
+
+static int foo (void* p) { return 0; }
+
+static int bar (void* p) { return 1; }
+
+int
+test (void* p)
+{
+  int res = !p ? foo(p) : bar(p);
+
+  register int tmp __asm__("$t0") = -1;
+  __asm__ (""::"r"(tmp));
+
+  return res;
+}
+
+/* { dg-final { scan-assembler-not "\\\.reloc\t1f,R_MIPS_JALR,foo" } } */
+/* { dg-final { scan-assembler-not "\\\.reloc\t1f,R_MIPS_JALR,bar" } } */
+/* { dg-final { scan-assembler "\\.set\tnomacro\n\tjalr\t\\\$25" } } */