aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2017-04-25 12:15:44 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2017-04-25 12:15:44 +0000
commitbed3fd4637d24e27b61fbd7f366e98a211080a0b (patch)
tree690cd4fd07d5f180a7f6871949ce641cfc7e1daf
parentca0b6141fa6a9c98939224ebc3b7ddc171df5b96 (diff)
downloadgcc-bed3fd4637d24e27b61fbd7f366e98a211080a0b.zip
gcc-bed3fd4637d24e27b61fbd7f366e98a211080a0b.tar.gz
gcc-bed3fd4637d24e27b61fbd7f366e98a211080a0b.tar.bz2
re PR tree-optimization/80492 (Wrong code when unrolling a loop with inline asm and local regs)
2017-04-25 Richard Biener <rguenther@suse.de> PR tree-optimization/80492 * alias.c (compare_base_decls): Handle registers with asm specification conservatively. * tree-ssa-alias.c (decl_refs_may_alias_p): Handle compare_base_decls returning dont-know properly. * gcc.dg/pr80492.c: New testcase. From-SVN: r247208
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/alias.c12
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/pr80492.c20
-rw-r--r--gcc/tree-ssa-alias.c7
5 files changed, 50 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2f41647..4156779 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2017-04-25 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/80492
+ * alias.c (compare_base_decls): Handle registers with asm
+ specification conservatively.
+ * tree-ssa-alias.c (decl_refs_may_alias_p): Handle
+ compare_base_decls returning dont-know properly.
+
2017-04-25 Claudiu Zissulescu <claziss@synopsys.com>
* config/arc/arc.c (LEGITIMATE_OFFSET_ADDRESS_P): Delete macro.
diff --git a/gcc/alias.c b/gcc/alias.c
index efd89ce..e16e350 100644
--- a/gcc/alias.c
+++ b/gcc/alias.c
@@ -2046,6 +2046,18 @@ compare_base_decls (tree base1, tree base2)
if (base1 == base2)
return 1;
+ /* If we have two register decls with register specification we
+ cannot decide unless their assembler name is the same. */
+ if (DECL_REGISTER (base1)
+ && DECL_REGISTER (base2)
+ && DECL_ASSEMBLER_NAME_SET_P (base1)
+ && DECL_ASSEMBLER_NAME_SET_P (base2))
+ {
+ if (DECL_ASSEMBLER_NAME (base1) == DECL_ASSEMBLER_NAME (base2))
+ return 1;
+ return -1;
+ }
+
/* Declarations of non-automatic variables may have aliases. All other
decls are unique. */
if (!decl_in_symtab_p (base1)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index fd6b9fa..576838e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2017-04-25 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/80492
+ * gcc.dg/pr80492.c: New testcase.
+
2017-04-25 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>
* gcc.dg/attr-alloc_size-10.c: Ignore overflow warnings
diff --git a/gcc/testsuite/gcc.dg/pr80492.c b/gcc/testsuite/gcc.dg/pr80492.c
new file mode 100644
index 0000000..1721b2d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr80492.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-w -O2 -fdump-tree-optimized" } */
+
+static __inline__ __attribute__((__always_inline__))
+void syscall_7 (int val)
+{
+ register int reg __asm ("4") = val;
+ __asm __volatile__ ("/* Some Code %0 */" :: "r" (reg));
+}
+
+void do_syscalls (void)
+{
+ for (int s = 0; s < 2; s++)
+ {
+ syscall_7 (0);
+ syscall_7 (1);
+ }
+}
+
+/* { dg-final { scan-tree-dump-times "reg = " 4 "optimized" } } */
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
index 3f0c650..0dcb273 100644
--- a/gcc/tree-ssa-alias.c
+++ b/gcc/tree-ssa-alias.c
@@ -1096,13 +1096,16 @@ decl_refs_may_alias_p (tree ref1, tree base1,
{
gcc_checking_assert (DECL_P (base1) && DECL_P (base2));
+ int cmp = compare_base_decls (base1, base2);
+
/* If both references are based on different variables, they cannot alias. */
- if (compare_base_decls (base1, base2) == 0)
+ if (cmp == 0)
return false;
/* If both references are based on the same variable, they cannot alias if
the accesses do not overlap. */
- if (!ranges_overlap_p (offset1, max_size1, offset2, max_size2))
+ if (cmp == 1
+ && !ranges_overlap_p (offset1, max_size1, offset2, max_size2))
return false;
/* For components with variable position, the above test isn't sufficient,