Commit 72d50660 by Richard Biener Committed by Richard Biener

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
parent 988c115c
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.
2016-06-08 Jakub Jelinek <jakub@redhat.com>
Richard Biener <rguenther@suse.de>
......
2016-06-08 Richard Biener <rguenther@suse.de>
PR tree-optimization/71452
* gcc.dg/torture/pr71452.c: New testcase.
2016-06-08 Jakub Jelinek <jakub@redhat.com>
PR c++/71448
......
/* { dg-do run } */
int main()
{
_Bool b;
*(char *)&b = 123;
if (*(char *)&b != 123)
__builtin_abort ();
return 0;
}
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment