PR tree-optimization/33453
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 3 Dec 2007 22:35:39 +0000 (22:35 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 3 Dec 2007 22:35:39 +0000 (22:35 +0000)
* tree-data-ref.c (split_constant_offset): Use POINTER_PLUS_EXPR
for pointer addition.
* tree-parloops.c (canonicalize_loop_ivs): Likewise.
(separate_decls_in_loop_name): Copy DECL_GIMPLE_REG_P from var to
var_copy.

* gcc.c-torture/compile/20071203-1.c: New test.

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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/20071203-1.c [new file with mode: 0644]
gcc/tree-data-ref.c
gcc/tree-parloops.c

index e6769e3..2d405bc 100644 (file)
@@ -1,3 +1,12 @@
+2007-12-03  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/33453
+       * tree-data-ref.c (split_constant_offset): Use POINTER_PLUS_EXPR
+       for pointer addition.
+       * tree-parloops.c (canonicalize_loop_ivs): Likewise.
+       (separate_decls_in_loop_name): Copy DECL_GIMPLE_REG_P from var to
+       var_copy.
+
 2007-12-03  Bernd Schmidt  <bernd.schmidt@analog.com>
 
        * config/bfin/bfin.h (TARGET_CPU_CPP_BUILTINS): Define __FDPIC__ as
@@ -5,8 +14,7 @@
 
 2007-12-03  Razya Ladelsky <razya@il.ibm.com>
 
-    * doc/invoke.texi (fipa-cp, fipa-matrix-reorg): Add documentation.
-
+       * doc/invoke.texi (fipa-cp, fipa-matrix-reorg): Add documentation.
 
 2007-12-03  Jakub Jelinek  <jakub@redhat.com>
 
index 2dd999b..dc8bb82 100644 (file)
@@ -1,3 +1,8 @@
+2007-12-03  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/33453
+       * gcc.c-torture/compile/20071203-1.c: New test.
+
 2007-12-03  Robert Dewar <dewar@adacore.com>
             Samuel Tardieu  <sam@rfc1149.net>
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/20071203-1.c b/gcc/testsuite/gcc.c-torture/compile/20071203-1.c
new file mode 100644 (file)
index 0000000..154b28b
--- /dev/null
@@ -0,0 +1,12 @@
+/* Testcase by Martin Michlmayr <tbm@cyrius.com> */
+
+struct User { char username[10]; };
+
+void
+auth_set_username (struct User *user)
+{
+  char *d;
+  char ch;
+  d = user->username + (user->username[0] == '~');
+  while ((ch = *d++) != '\0') /* do nothing */ ;
+}
index 8d9c4c9..89a0039 100644 (file)
@@ -555,9 +555,12 @@ split_constant_offset (tree exp, tree *var, tree *off)
          {
            split_constant_offset (poffset, &poffset, &off1);
            off0 = size_binop (PLUS_EXPR, off0, off1);
-           base = fold_build2 (PLUS_EXPR, TREE_TYPE (base),
-                               base,
-                               fold_convert (TREE_TYPE (base), poffset));
+           if (POINTER_TYPE_P (TREE_TYPE (base)))
+             base = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (base),
+                                 base, fold_convert (sizetype, poffset));
+           else
+             base = fold_build2 (PLUS_EXPR, TREE_TYPE (base), base,
+                                 fold_convert (TREE_TYPE (base), poffset));
          }
 
        var0 = fold_convert (type, base);
index dafcdaa..b4f8519 100644 (file)
@@ -687,6 +687,7 @@ separate_decls_in_loop_name (tree name,
   if (!*dslot)
     {
       var_copy = create_tmp_var (TREE_TYPE (var), get_name (var));
+      DECL_GIMPLE_REG_P (var_copy) = DECL_GIMPLE_REG_P (var);
       add_referenced_var (var_copy);
       nielt = XNEW (struct int_tree_map);
       nielt->uid = uid;
@@ -1266,7 +1267,7 @@ static void
 canonicalize_loop_ivs (struct loop *loop, htab_t reduction_list, tree nit)
 {
   unsigned precision = TYPE_PRECISION (TREE_TYPE (nit));
-  tree phi, prev, res, type, var_before, val, atype, t, next;
+  tree phi, prev, res, type, var_before, val, atype, mtype, t, next;
   block_stmt_iterator bsi;
   bool ok;
   affine_iv iv;
@@ -1313,11 +1314,12 @@ canonicalize_loop_ivs (struct loop *loop, htab_t reduction_list, tree nit)
       remove_phi_node (phi, prev, false);
 
       atype = TREE_TYPE (res);
-      val = fold_build2 (PLUS_EXPR, atype,
-                        unshare_expr (iv.base),
-                        fold_build2 (MULT_EXPR, atype,
-                                     unshare_expr (iv.step),
-                                     fold_convert (atype, var_before)));
+      mtype = POINTER_TYPE_P (atype) ? sizetype : atype;
+      val = fold_build2 (MULT_EXPR, mtype, unshare_expr (iv.step),
+                        fold_convert (mtype, var_before));
+      val = fold_build2 (POINTER_TYPE_P (atype)
+                        ? POINTER_PLUS_EXPR : PLUS_EXPR,
+                        atype, unshare_expr (iv.base), val);
       val = force_gimple_operand_bsi (&bsi, val, false, NULL_TREE, true,
                                      BSI_SAME_STMT);
       t = build_gimple_modify_stmt (res, val);