OSDN Git Service

2007-04-12 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 12 Apr 2007 09:15:53 +0000 (09:15 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 12 Apr 2007 09:15:53 +0000 (09:15 +0000)
PR tree-optimization/24689
PR tree-optimization/31307
* fold-const.c (operand_equal_p): Compare INTEGER_CST array
indices by value.
* gimplify.c (canonicalize_addr_expr): To be consistent with
gimplify_compound_lval only set operands two and three of
ARRAY_REFs if they are not gimple_min_invariant.  This makes
it never at this place.
* tree-ssa-ccp.c (maybe_fold_offset_to_array_ref): Likewise.

* g++.dg/tree-ssa/pr31307.C: New testcase.
* gcc.dg/tree-ssa/pr24689.c: Likewise.

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

gcc/ChangeLog
gcc/fold-const.c
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/tree-ssa/pr31307.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/pr24689.c [new file with mode: 0644]
gcc/tree-ssa-ccp.c

index 372f42f..d8a3c65 100644 (file)
@@ -1,3 +1,15 @@
+2007-04-12  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/24689
+       PR tree-optimization/31307
+       * fold-const.c (operand_equal_p): Compare INTEGER_CST array
+       indices by value.
+       * gimplify.c (canonicalize_addr_expr): To be consistent with
+       gimplify_compound_lval only set operands two and three of
+       ARRAY_REFs if they are not gimple_min_invariant.  This makes
+       it never at this place.
+       * tree-ssa-ccp.c (maybe_fold_offset_to_array_ref): Likewise.
+
 2007-04-11  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
 
        * pa.c (pa_som_asm_init_sections): Ensure that cfun->machine is not
index ceaa446..857065f 100644 (file)
@@ -2884,9 +2884,13 @@ operand_equal_p (tree arg0, tree arg1, unsigned int flags)
 
        case ARRAY_REF:
        case ARRAY_RANGE_REF:
-         /* Operands 2 and 3 may be null.  */
+         /* Operands 2 and 3 may be null.
+            Compare the array index by value if it is constant first as we
+            may have different types but same value here.  */
          return (OP_SAME (0)
-                 && OP_SAME (1)
+                 && (tree_int_cst_equal (TREE_OPERAND (arg0, 1),
+                                         TREE_OPERAND (arg1, 1))
+                     || OP_SAME (1))
                  && OP_SAME_WITH_NULL (2)
                  && OP_SAME_WITH_NULL (3));
 
index 8bedd86..0b6ec34 100644 (file)
@@ -1607,9 +1607,7 @@ canonicalize_addr_expr (tree *expr_p)
   /* All checks succeeded.  Build a new node to merge the cast.  */
   *expr_p = build4 (ARRAY_REF, dctype, obj_expr,
                    TYPE_MIN_VALUE (TYPE_DOMAIN (datype)),
-                   TYPE_MIN_VALUE (TYPE_DOMAIN (datype)),
-                   size_binop (EXACT_DIV_EXPR, TYPE_SIZE_UNIT (dctype),
-                               size_int (TYPE_ALIGN_UNIT (dctype))));
+                   NULL_TREE, NULL_TREE);
   *expr_p = build1 (ADDR_EXPR, ctype, *expr_p);
 }
 
index dfe1f30..f431bcb 100644 (file)
@@ -1,3 +1,10 @@
+2007-04-12  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/24689
+       PR tree-optimization/31307
+       * g++.dg/tree-ssa/pr31307.C: New testcase.
+       * gcc.dg/tree-ssa/pr24689.c: Likewise.
+
 2007-04-12  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/31472
diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr31307.C b/gcc/testsuite/g++.dg/tree-ssa/pr31307.C
new file mode 100644 (file)
index 0000000..bdfe5bd
--- /dev/null
@@ -0,0 +1,40 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-optimized" } */
+
+union MY_M128
+{
+  double i;
+};
+
+struct RegFile
+{
+  MY_M128 dst[4];
+};
+
+__inline__ __attribute__((always_inline)) static void
+MEM_OPT_LOAD(MY_M128* reg, double* mem)
+{
+  reg[0].i = *mem;
+}
+
+void _ia32_movntdq (double *, double);
+
+__inline__ __attribute__((always_inline)) static void
+MEM_OPT_STORE(MY_M128* reg, double* mem)
+{
+  _ia32_movntdq ((double*)mem, (double)reg[0].i);
+}
+
+double _mm_adds_epu8 (double __A, double __B);
+
+int test(unsigned char *d)
+{ 
+  RegFile r;
+  MEM_OPT_LOAD((r.dst) , ((double*) d)); 
+  r.dst[0].i = _mm_adds_epu8(r.dst[0].i, r.dst[0].i);
+  MEM_OPT_STORE((r.dst), (double*) d);
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-not "r.dst" "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr24689.c b/gcc/testsuite/gcc.dg/tree-ssa/pr24689.c
new file mode 100644 (file)
index 0000000..4fe74b6
--- /dev/null
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-optimized" } */
+
+extern void bar (unsigned int);
+
+int
+foo (void)
+{
+  char buf[1] = { 3 };
+  const char *p = buf;
+  const char **q = &p;
+  unsigned int ch;
+  switch (**q)
+    {
+    case 1:  ch = 5; break;
+    default: ch = 0; break;
+    }
+
+  bar (ch);
+  return ch;
+}
+
+/* { dg-final { scan-tree-dump "return 0;" "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
index 8e4d88c..530dee0 100644 (file)
@@ -1632,9 +1632,7 @@ maybe_fold_offset_to_array_ref (tree base, tree offset, tree orig_type)
   if (!integer_zerop (elt_offset))
     idx = int_const_binop (PLUS_EXPR, idx, elt_offset, 0);
 
-  return build4 (ARRAY_REF, orig_type, base, idx, min_idx,
-                size_int (tree_low_cst (elt_size, 1)
-                          / (TYPE_ALIGN_UNIT (elt_type))));
+  return build4 (ARRAY_REF, orig_type, base, idx, NULL_TREE, NULL_TREE);
 }