OSDN Git Service

PR rtl-optimization/49235
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 31 May 2011 12:34:42 +0000 (12:34 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 31 May 2011 12:34:42 +0000 (12:34 +0000)
* tree-ssa-address.c (gen_addr_rtx): Ignore base if it is const0_rtx.
(create_mem_ref_raw): Create MEM_REF even if base is INTEGER_CST.

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

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@174478 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 4270d2d..c416db5 100644 (file)
@@ -1,3 +1,9 @@
+2011-05-31  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/49235
+       * tree-ssa-address.c (gen_addr_rtx): Ignore base if it is const0_rtx.
+       (create_mem_ref_raw): Create MEM_REF even if base is INTEGER_CST.
+
 2011-05-31  Ira Rosen  <ira.rosen@linaro.org>
 
        PR tree-optimization/49093
index 612fc17..7f9a50c 100644 (file)
@@ -1,3 +1,8 @@
+2011-05-31  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/49235
+       * gcc.dg/pr49235.c: New test.
+
 2011-05-31  Ira Rosen  <ira.rosen@linaro.org>
 
        PR tree-optimization/49093
diff --git a/gcc/testsuite/gcc.dg/pr49235.c b/gcc/testsuite/gcc.dg/pr49235.c
new file mode 100644 (file)
index 0000000..f1e589f
--- /dev/null
@@ -0,0 +1,25 @@
+/* PR rtl-optimization/49235 */
+/* { dg-do compile { target { int32plus } } } */
+/* { dg-options "-O -fno-delete-null-pointer-checks -fno-tree-scev-cprop -ftree-vectorize -fno-vect-cost-model -w" } */
+
+void
+foo (void)
+{
+  unsigned i;
+  unsigned *p = 0;
+  for (i = 0; i < 4; ++i)
+    *p++ = 0;
+  for (i = 0; i < 4; ++i)
+    *p++ = 0;
+}
+
+void
+bar (void)
+{
+  unsigned i;
+  unsigned *p = (unsigned *) (__UINTPTR_TYPE__) 0x12340000;
+  for (i = 0; i < 4; ++i)
+    *p++ = 0;
+  for (i = 0; i < 4; ++i)
+    *p++ = 0;
+}
index 2e6eabc..e3934e1 100644 (file)
@@ -1,5 +1,5 @@
 /* Memory address lowering and addressing mode selection.
-   Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010
+   Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010, 2011
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -129,7 +129,7 @@ gen_addr_rtx (enum machine_mode address_mode,
       *addr = act_elem;
     }
 
-  if (base)
+  if (base && base != const0_rtx)
     {
       if (*addr)
        *addr = simplify_gen_binary (PLUS, address_mode, base, *addr);
@@ -365,7 +365,7 @@ create_mem_ref_raw (tree type, tree alias_ptr_type, struct mem_address *addr,
      ???  As IVOPTs does not follow restrictions to where the base
      pointer may point to create a MEM_REF only if we know that
      base is valid.  */
-  if (TREE_CODE (base) == ADDR_EXPR
+  if ((TREE_CODE (base) == ADDR_EXPR || TREE_CODE (base) == INTEGER_CST)
       && (!index2 || integer_zerop (index2))
       && (!addr->index || integer_zerop (addr->index)))
     return fold_build2 (MEM_REF, type, base, addr->offset);