OSDN Git Service

* gimple-fold.c (gimple_fold_stmt_to_constant_1) <GIMPLE_UNARY_RHS>:
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 9 Dec 2011 21:11:21 +0000 (21:11 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 9 Dec 2011 21:11:21 +0000 (21:11 +0000)
Also check the TYPE_MODE to recognize useless pointer conversions.

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

gcc/ChangeLog
gcc/gimple-fold.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/20111209-1.c [new file with mode: 0644]

index 0400f1b..4cc5072 100644 (file)
@@ -1,3 +1,8 @@
+2011-12-09  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gimple-fold.c (gimple_fold_stmt_to_constant_1) <GIMPLE_UNARY_RHS>:
+       Also check the TYPE_MODE to recognize useless pointer conversions.
+
 2011-12-09  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/51117
index 5da9be3..91dd8fc 100644 (file)
@@ -2517,8 +2517,10 @@ gimple_fold_stmt_to_constant_1 (gimple stmt, tree (*valueize) (tree))
              if (CONVERT_EXPR_CODE_P (subcode)
                  && POINTER_TYPE_P (TREE_TYPE (lhs))
                  && POINTER_TYPE_P (TREE_TYPE (op0))
-                 && (TYPE_ADDR_SPACE (TREE_TYPE (lhs))
-                     == TYPE_ADDR_SPACE (TREE_TYPE (op0))))
+                 && TYPE_ADDR_SPACE (TREE_TYPE (lhs))
+                    == TYPE_ADDR_SPACE (TREE_TYPE (op0))
+                 && TYPE_MODE (TREE_TYPE (lhs))
+                    == TYPE_MODE (TREE_TYPE (op0)))
                return op0;
 
               return
index 5c3e51b..ac300e8 100644 (file)
@@ -1,3 +1,7 @@
+2011-12-09  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc.c-torture/compile/20111209-1.c: New test.
+
 2011-12-09  Jason Merrill  <jason@redhat.com>
 
        PR c++/51151
diff --git a/gcc/testsuite/gcc.c-torture/compile/20111209-1.c b/gcc/testsuite/gcc.c-torture/compile/20111209-1.c
new file mode 100644 (file)
index 0000000..c7f832a
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do compile { target s390x-*-* *-*-*vms* } } */
+
+typedef char* char_ptr32 __attribute__ ((mode(SI)));
+
+char_ptr32 getenv (const char *name);
+unsigned long strlen (const char *str);
+
+void
+__gnat_getenv (char *name, int *len, char **value)
+{
+  *value = getenv (name);
+  *len = strlen (*value);
+}