From patchwork Thu Jan 12 23:09:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: useless_type_conversion_p vs pointer sizes Date: Thu, 12 Jan 2012 13:09:29 -0000 From: DJ Delorie X-Patchwork-Id: 135695 Message-Id: <201201122309.q0CN9T8o027553@greed.delorie.com> To: gcc-patches@gcc.gnu.org Another case where one address space may support multiple pointer sizes, so conversions between such must be preserved. * tree-ssa.c (useless_type_conversion_p): Conversions between different-sized pointers aren't useless. Index: tree-ssa.c =================================================================== --- tree-ssa.c (revision 183139) +++ tree-ssa.c (working copy) @@ -1192,12 +1192,17 @@ bool useless_type_conversion_p (tree outer_type, tree inner_type) { /* Do the following before stripping toplevel qualifiers. */ if (POINTER_TYPE_P (inner_type) && POINTER_TYPE_P (outer_type)) { + /* Do not lose casts between pointers of different precision. */ + if (TYPE_PRECISION (outer_type) + != TYPE_PRECISION (inner_type)) + return false; + /* Do not lose casts between pointers to different address spaces. */ if (TYPE_ADDR_SPACE (TREE_TYPE (outer_type)) != TYPE_ADDR_SPACE (TREE_TYPE (inner_type))) return false; /* If the outer type is (void *), the conversion is not necessary. */