From 4c44c315d4f300b0effee18306c026f05a29bcb8 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 8 Jul 2008 18:34:37 +0200 Subject: [PATCH] tree-sra.c (sra_build_assignment): Handle CONVERT_EXPR_P dst. * tree-sra.c (sra_build_assignment): Handle CONVERT_EXPR_P dst. From-SVN: r137633 --- gcc/ChangeLog | 5 +++++ gcc/tree-sra.c | 13 +++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e88d5d3c3d34..b93a55d879d2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2008-07-08 Jakub Jelinek + + * tree-sra.c (sra_build_assignment): Handle CONVERT_EXPR_P + dst. + 2008-07-05 Daniel Berlin Fix PR tree-optimization/23455 diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index c50c6cd225bf..16f719e5ecb2 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -2282,6 +2282,9 @@ sra_build_assignment (tree dst, tree src) var = utmp; } + /* fold_build3 (BIT_FIELD_REF, ...) sometimes returns a cast. */ + STRIP_NOPS (dst); + /* Finally, move and convert to the destination. */ if (!useless_type_conversion_p (TREE_TYPE (dst), TREE_TYPE (var))) { @@ -2306,6 +2309,12 @@ sra_build_assignment (tree dst, tree src) return list; } + /* fold_build3 (BIT_FIELD_REF, ...) sometimes returns a cast. */ + if (CONVERT_EXPR_P (dst)) + { + STRIP_NOPS (dst); + src = fold_convert (TREE_TYPE (dst), src); + } /* It was hoped that we could perform some type sanity checking here, but since front-ends can emit accesses of fields in types different from their nominal types and copy structures containing @@ -2316,8 +2325,8 @@ sra_build_assignment (tree dst, tree src) So we just assume type differences at this point are ok. The only exception we make here are pointer types, which can be different in e.g. structurally equal, but non-identical RECORD_TYPEs. */ - if (POINTER_TYPE_P (TREE_TYPE (dst)) - && !useless_type_conversion_p (TREE_TYPE (dst), TREE_TYPE (src))) + else if (POINTER_TYPE_P (TREE_TYPE (dst)) + && !useless_type_conversion_p (TREE_TYPE (dst), TREE_TYPE (src))) src = fold_convert (TREE_TYPE (dst), src); return build_gimple_modify_stmt (dst, src); -- 2.47.2