This fixes PR50780 by validating a condition is gimple before
substituting it into a COND_EXPR during forwprop.  When looking
at this I noticed that comparisons no longer are marked as
possibly throwing - because of an old tuplification bug :/
Thus, fixed as well, hopefully without fallout.

Bootstrap and regtest running on x86_64-unknown-linux-gnu ...

Richard.

2011-10-19  Richard Guenther  <rguent...@suse.de>

        PR middle-end/50780
        * tree-ssa-forwprop.c (forward_propagate_into_cond): Verify
        the condition is properly gimple before using it.
        * tree-eh (stmt_could_throw_1_p): Properly extract the
        operation type from comparisons.

Index: gcc/tree-ssa-forwprop.c
===================================================================
*** gcc/tree-ssa-forwprop.c     (revision 180186)
--- gcc/tree-ssa-forwprop.c     (working copy)
*************** forward_propagate_into_cond (gimple_stmt
*** 597,603 ****
        }
      }
  
!   if (tmp)
      {
        if (dump_file && tmp)
        {
--- 597,604 ----
        }
      }
  
!   if (tmp
!       && is_gimple_condexpr (tmp))
      {
        if (dump_file && tmp)
        {
Index: gcc/tree-eh.c
===================================================================
*** gcc/tree-eh.c       (revision 180186)
--- gcc/tree-eh.c       (working copy)
*************** stmt_could_throw_1_p (gimple stmt)
*** 2512,2518 ****
        || TREE_CODE_CLASS (code) == tcc_unary
        || TREE_CODE_CLASS (code) == tcc_binary)
      {
!       t = gimple_expr_type (stmt);
        fp_operation = FLOAT_TYPE_P (t);
        if (fp_operation)
        {
--- 2512,2524 ----
        || TREE_CODE_CLASS (code) == tcc_unary
        || TREE_CODE_CLASS (code) == tcc_binary)
      {
!       if (is_gimple_assign (stmt)
!         && TREE_CODE_CLASS (code) == tcc_comparison)
!       t = TREE_TYPE (gimple_assign_rhs1 (stmt));
!       else if (gimple_code (stmt) == GIMPLE_COND)
!       t = TREE_TYPE (gimple_cond_lhs (stmt));
!       else
!       t = gimple_expr_type (stmt);
        fp_operation = FLOAT_TYPE_P (t);
        if (fp_operation)
        {

Reply via email to