[PATCH][mem-ref2] Fix some ICEs and wrong-codes
Richard Guenther
rguenther@suse.de
Mon Jun 7 11:58:00 GMT 2010
This fixes some ICEs and wrong-codes that have appeared during the
last merges. It also removes the restriction on volatile pointer
conversions which isn't necessary anymore.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to the
branch.
Richard.
2010-06-07 Richard Guenther <rguenther@suse.de>
cp/
* cp-gimplify.c (cp_gimplify_expr): Open-code the rhs
predicate we are looking for, allow non-gimplified
INDIRECT_REFs.
* gimplify.c (gimplify_cond_expr): Make sure to build MEM_REFs when
returning GS_ALL_DONE.
(gimplify_cleanup_point_expr): For empty body and EH-only cleanup
drop the cleanup instead of inserting it unconditionally.
* tree-ssa.c (useless_type_conversion_p): Also drop pointer conversions
with differing pointed-to volatile qualifiers.
* gcc.dg/volatile2.c: Adjust.
Index: gcc/cp/cp-gimplify.c
===================================================================
*** gcc/cp/cp-gimplify.c (revision 160359)
--- gcc/cp/cp-gimplify.c (working copy)
*************** cp_gimplify_expr (tree *expr_p, gimple_s
*** 575,581 ****
TREE_OPERAND (*expr_p, 1) = build1 (VIEW_CONVERT_EXPR,
TREE_TYPE (op0), op1);
! else if ((rhs_predicate_for (op0)) (op1)
&& !(TREE_CODE (op1) == CALL_EXPR
&& CALL_EXPR_RETURN_SLOT_OPT (op1))
&& is_really_empty_class (TREE_TYPE (op0)))
--- 575,581 ----
TREE_OPERAND (*expr_p, 1) = build1 (VIEW_CONVERT_EXPR,
TREE_TYPE (op0), op1);
! else if ((is_gimple_lvalue (op1) || INDIRECT_REF_P (op1))
&& !(TREE_CODE (op1) == CALL_EXPR
&& CALL_EXPR_RETURN_SLOT_OPT (op1))
&& is_really_empty_class (TREE_TYPE (op0)))
Index: gcc/gimplify.c
===================================================================
*** gcc/gimplify.c (revision 160359)
--- gcc/gimplify.c (working copy)
*************** gimplify_cond_expr (tree *expr_p, gimple
*** 2969,2975 ****
= build3 (COND_EXPR, type, TREE_OPERAND (expr, 0), then_, else_);
tmp = create_tmp_var (type, "iftmp");
! result = build_fold_indirect_ref_loc (loc, tmp);
}
/* Build the new then clause, `tmp = then_;'. But don't build the
--- 2969,2975 ----
= build3 (COND_EXPR, type, TREE_OPERAND (expr, 0), then_, else_);
tmp = create_tmp_var (type, "iftmp");
! result = build_simple_mem_ref_loc (loc, tmp);
}
/* Build the new then clause, `tmp = then_;'. But don't build the
*************** gimplify_cleanup_point_expr (tree *expr_
*** 5147,5155 ****
{
/* Note that gsi_insert_seq_before and gsi_remove do not
scan operands, unlike some other sequence mutators. */
! gsi_insert_seq_before_without_update (&iter,
! gimple_wce_cleanup (wce),
! GSI_SAME_STMT);
gsi_remove (&iter, true);
break;
}
--- 5147,5156 ----
{
/* Note that gsi_insert_seq_before and gsi_remove do not
scan operands, unlike some other sequence mutators. */
! if (!gimple_wce_cleanup_eh_only (wce))
! gsi_insert_seq_before_without_update (&iter,
! gimple_wce_cleanup (wce),
! GSI_SAME_STMT);
gsi_remove (&iter, true);
break;
}
Index: gcc/tree-ssa.c
===================================================================
*** gcc/tree-ssa.c (revision 160359)
--- gcc/tree-ssa.c (working copy)
*************** useless_type_conversion_p (tree outer_ty
*** 1273,1291 ****
else if (POINTER_TYPE_P (inner_type)
&& POINTER_TYPE_P (outer_type))
{
- /* Don't lose casts between pointers to volatile and non-volatile
- qualified types. Doing so would result in changing the semantics
- of later accesses. For function types the volatile qualifier
- is used to indicate noreturn functions. */
- if (TREE_CODE (TREE_TYPE (outer_type)) != FUNCTION_TYPE
- && TREE_CODE (TREE_TYPE (outer_type)) != METHOD_TYPE
- && TREE_CODE (TREE_TYPE (inner_type)) != FUNCTION_TYPE
- && TREE_CODE (TREE_TYPE (inner_type)) != METHOD_TYPE
- && (TYPE_VOLATILE (TREE_TYPE (outer_type))
- != TYPE_VOLATILE (TREE_TYPE (inner_type)))
- && TYPE_VOLATILE (TREE_TYPE (outer_type)))
- return false;
-
/* Do not lose casts to function pointer types. */
if ((TREE_CODE (TREE_TYPE (outer_type)) == FUNCTION_TYPE
|| TREE_CODE (TREE_TYPE (outer_type)) == METHOD_TYPE)
--- 1273,1278 ----
Index: gcc/testsuite/gcc.dg/volatile2.c
===================================================================
*** gcc/testsuite/gcc.dg/volatile2.c (revision 160359)
--- gcc/testsuite/gcc.dg/volatile2.c (working copy)
***************
*** 1,5 ****
/* { dg-do compile } */
! /* { dg-options "-O2 -fdump-tree-gimple -fdump-tree-optimized" } */
struct GTeth_desc
{
--- 1,5 ----
/* { dg-do compile } */
! /* { dg-options "-O2 -fdump-tree-optimized" } */
struct GTeth_desc
{
*************** struct GTeth_softc
*** 12,25 ****
void foo(struct GTeth_softc *sc)
{
! /* Verify that we retain the cast to (volatile struct GTeth_desc *)
! after gimplification and that we keep the volatileness on the
store until after optimization. */
volatile struct GTeth_desc *p = &sc->txq_desc[0];
p->ed_cmdsts = 0;
}
- /* { dg-final { scan-tree-dump "\\(volatile struct GTeth_desc \\*\\) D" "gimple" } } */
/* { dg-final { scan-tree-dump "{v}" "optimized" } } */
- /* { dg-final { cleanup-tree-dump "gimple" } } */
/* { dg-final { cleanup-tree-dump "optimized" } } */
--- 12,22 ----
void foo(struct GTeth_softc *sc)
{
! /* Verify that we retain the volatileness on the
store until after optimization. */
volatile struct GTeth_desc *p = &sc->txq_desc[0];
p->ed_cmdsts = 0;
}
/* { dg-final { scan-tree-dump "{v}" "optimized" } } */
/* { dg-final { cleanup-tree-dump "optimized" } } */
More information about the Gcc-patches
mailing list