summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2009-05-15 12:13:02 +0000
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2009-05-15 12:13:02 +0000
commitbd8d8d8190891d693eadea6c938b5eed2c031a70 (patch)
tree3515881bf8eb12526689a646dc2ac11b970093fe
parente9e5970b94ee90b8cdafd695aeb01683efff634b (diff)
downloadgcc-bd8d8d8190891d693eadea6c938b5eed2c031a70.tar.gz
* tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Also
recurse on an invariant address if a conversion from a pointer type to a wider integer type is involved. testsuite: * gcc.c-torture/compile/ptr-conv-1.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@147570 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/ptr-conv-1.c11
-rw-r--r--gcc/tree-ssa-forwprop.c6
4 files changed, 26 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 39cd78d0947..ac138cab0d4 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2009-05-15 Joseph Myers <joseph@codesourcery.com>
+
+ * tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Also
+ recurse on an invariant address if a conversion from a pointer
+ type to a wider integer type is involved.
+
2009-05-15 Jan Hubicka <jh@suse.cz>
* cgraph.c (dump_cgraph_node): Dump size/time/benefit.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2733cb52dfd..b8ab7d472eb 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2009-05-15 Joseph Myers <joseph@codesourcery.com>
+
+ * gcc.c-torture/compile/ptr-conv-1.c: New test.
+
2009-05-14 Ian Lance Taylor <iant@google.com>
* gcc.dg/Wcxx-compat-9.c: New testcase.
diff --git a/gcc/testsuite/gcc.c-torture/compile/ptr-conv-1.c b/gcc/testsuite/gcc.c-torture/compile/ptr-conv-1.c
new file mode 100644
index 00000000000..11dc8ce8957
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/ptr-conv-1.c
@@ -0,0 +1,11 @@
+/* The intermediate conversion to __PTRDIFF_TYPE__ could be lost,
+ resulting in an "invalid types in nop conversion" ICE. */
+long long a;
+void
+f (void)
+{
+ int c = 1;
+ volatile int *p = &c;
+ a = (long long) (__PTRDIFF_TYPE__) p;
+ *p;
+}
diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c
index 65b02af27f6..ef78703c8ee 100644
--- a/gcc/tree-ssa-forwprop.c
+++ b/gcc/tree-ssa-forwprop.c
@@ -739,7 +739,11 @@ forward_propagate_addr_expr_1 (tree name, tree def_rhs,
address which we cannot do in a single statement. */
if (!single_use_p
|| (!useless_type_conversion_p (TREE_TYPE (lhs), TREE_TYPE (def_rhs))
- && !is_gimple_min_invariant (def_rhs)))
+ && (!is_gimple_min_invariant (def_rhs)
+ || (INTEGRAL_TYPE_P (TREE_TYPE (lhs))
+ && POINTER_TYPE_P (TREE_TYPE (def_rhs))
+ && (TYPE_PRECISION (TREE_TYPE (lhs))
+ > TYPE_PRECISION (TREE_TYPE (def_rhs)))))))
return forward_propagate_addr_expr (lhs, def_rhs);
gimple_assign_set_rhs1 (use_stmt, unshare_expr (def_rhs));