re PR tree-optimization/66768 (address space gets lost on literal pointer)
authorBin Cheng <bin.cheng@arm.com>
Thu, 2 Mar 2017 11:25:11 +0000 (11:25 +0000)
committerBin Cheng <amker@gcc.gnu.org>
Thu, 2 Mar 2017 11:25:11 +0000 (11:25 +0000)
PR tree-optimization/66768
* tree-ssa-loop-ivopts.c (find_interesting_uses_address): Skip addr
iv_use if base object can't be determined.

gcc/testsuite
* gcc.target/i386/pr66768.c: New test.

From-SVN: r245837

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr66768.c [new file with mode: 0644]
gcc/tree-ssa-loop-ivopts.c

index 0909183385fb7b8bb93dfc9cfde7ba16d37982dd..8f196d7a99ca41d9b49b5a04cd5437f3bad7eb55 100644 (file)
@@ -1,3 +1,9 @@
+2017-03-02  Bin Cheng  <bin.cheng@arm.com>
+
+       PR tree-optimization/66768
+       * tree-ssa-loop-ivopts.c (find_interesting_uses_address): Skip addr
+       iv_use if base object can't be determined.
+
 2017-03-02  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/79345
index 8677d67e413b025ade219f7f45ae7c70191361c1..9f2315451b068f8add610c78f5945dfa76987bf7 100644 (file)
@@ -1,3 +1,8 @@
+2017-03-02  Bin Cheng  <bin.cheng@arm.com>
+
+       PR tree-optimization/66768
+       * gcc.target/i386/pr66768.c: New test.
+
 2017-03-02  Richard Biener  <rguenther@suse.de>
 
        * gcc.dg/rtl/x86_64/dfinit.c: Only run for lp64.
diff --git a/gcc/testsuite/gcc.target/i386/pr66768.c b/gcc/testsuite/gcc.target/i386/pr66768.c
new file mode 100644 (file)
index 0000000..9a8ad1f
--- /dev/null
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+typedef __seg_gs struct foo_s {
+  int a[20];
+} foo_t;
+
+int sum(void)
+{
+  const foo_t *p = (const foo_t *)0x1234;
+  int i, total=0;
+  for (i=0; i<20; i++)
+    total += p->a[i];
+  return total;
+}
+
+/* { dg-final { scan-assembler "add*.\[ \t\]%gs:" } } */
index c9d16b28ba0b6d5361eaf3a744f7de97ac45c0fc..f3ad3736698589a8b98262a19026ecb583d1c752 100644 (file)
@@ -2324,6 +2324,10 @@ find_interesting_uses_address (struct ivopts_data *data, gimple *stmt,
     }
 
   civ = alloc_iv (data, base, step);
+  /* Fail if base object of this memory reference is unknown.  */
+  if (civ->base_object == NULL_TREE)
+    goto fail;
+
   record_group_use (data, op_p, civ, stmt, USE_ADDRESS);
   return;