aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2016-06-08 13:11:43 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2016-06-08 13:11:43 +0000
commit72d50660ad57224cefc7ad40b81c994b49a503b6 (patch)
tree91404c94ca65e268950f891ecf25f02f3c2cbd3b /gcc/tree-ssa.c
parent988c115ca0fee432e5d6823a44e3289c0b73ad15 (diff)
downloadgcc-72d50660ad57224cefc7ad40b81c994b49a503b6.zip
gcc-72d50660ad57224cefc7ad40b81c994b49a503b6.tar.gz
gcc-72d50660ad57224cefc7ad40b81c994b49a503b6.tar.bz2
re PR tree-optimization/71452 (Wrong optimization of stores to _Bool via char*)
2016-06-08 Richard Biener <rguenther@suse.de> PR tree-optimization/71452 * tree-ssa.c (non_rewritable_lvalue_p): Make sure that the type used for the SSA rewrite has enough precision to cover the dynamic type of the location. * gcc.dg/torture/pr71452.c: New testcase. From-SVN: r237214
Diffstat (limited to 'gcc/tree-ssa.c')
-rw-r--r--gcc/tree-ssa.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c
index 2f3caf3..30c6269 100644
--- a/gcc/tree-ssa.c
+++ b/gcc/tree-ssa.c
@@ -1292,6 +1292,14 @@ non_rewritable_lvalue_p (tree lhs)
if (integer_zerop (TREE_OPERAND (lhs, 1))
&& DECL_P (decl)
&& DECL_SIZE (decl) == TYPE_SIZE (TREE_TYPE (lhs))
+ /* If the dynamic type of the decl has larger precision than
+ the decl itself we can't use the decls type for SSA rewriting. */
+ && ((! INTEGRAL_TYPE_P (TREE_TYPE (decl))
+ || compare_tree_int (DECL_SIZE (decl),
+ TYPE_PRECISION (TREE_TYPE (decl))) == 0)
+ || (INTEGRAL_TYPE_P (TREE_TYPE (lhs))
+ && (TYPE_PRECISION (TREE_TYPE (decl))
+ >= TYPE_PRECISION (TREE_TYPE (lhs)))))
&& (TREE_THIS_VOLATILE (decl) == TREE_THIS_VOLATILE (lhs)))
return false;