[tree-ssa-address] Avoid creating non-canonical RTL in gen_addr_rtx
authorKyrylo Tkachov <kyrylo.tkachov@arm.com>
Mon, 9 Jan 2017 09:42:10 +0000 (09:42 +0000)
committerKyrylo Tkachov <ktkachov@gcc.gnu.org>
Mon, 9 Jan 2017 09:42:10 +0000 (09:42 +0000)
* tree-ssa-address.c (gen_addr_rtx): Don't handle index if it
is const0_rtx.

* gcc.dg/20161219.c: New test.

From-SVN: r244219

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/20161219.c [new file with mode: 0644]
gcc/tree-ssa-address.c

index 96f3c2e615d272e569d74d65bdda5aabb07efc47..540c2bdf75fe92913ad3eabc3f26addaedf2b1c0 100644 (file)
@@ -1,3 +1,8 @@
+2017-01-09  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
+
+       * tree-ssa-address.c (gen_addr_rtx): Don't handle index if it
+       is const0_rtx.
+
 2017-01-09  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/78997
index 053d2cf76f18c2e579fb8d55bb2f2d0e62f737cd..14e24a8c3c14e1abf42b10253ec2471b90febb23 100644 (file)
@@ -1,3 +1,7 @@
+2017-01-09  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
+
+       * gcc.dg/20161219.c: New test.
+
 2017-01-09  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/78997
diff --git a/gcc/testsuite/gcc.dg/20161219.c b/gcc/testsuite/gcc.dg/20161219.c
new file mode 100644 (file)
index 0000000..93ea8d2
--- /dev/null
@@ -0,0 +1,30 @@
+/* { dg-do assemble } */
+/* { dg-options "-O1 -w" } */
+
+static long long a[9];
+int b, c, d, e, g;
+
+static int
+fn1 (int *p1)
+{
+  b = 1;
+  for (; b >= 0; b--)
+    {
+      d = 0;
+      for (;; d++)
+       {
+         e && (a[d] = 0);
+         if (*p1)
+           break;
+         c = (int) a;
+       }
+    }
+  return 0;
+}
+
+int
+main ()
+{
+  int f = fn1 ((int *) f);
+  return f;
+}
index 3e3cad150b64e813509e079f9ea91d65806e414a..8d46a3e67337dd7639d0b17ca888f50009d65b93 100644 (file)
@@ -115,7 +115,7 @@ gen_addr_rtx (machine_mode address_mode,
   if (offset_p)
     *offset_p = NULL;
 
-  if (index)
+  if (index && index != const0_rtx)
     {
       act_elem = index;
       if (step)