[PATCH](ping) Fix PR15911, VRP for && and ||

Richard Guenther rguenther@suse.de
Tue Oct 24 09:50:00 GMT 2006


On Mon, 23 Oct 2006, Richard Guenther wrote:

> On Mon, 23 Oct 2006, Richard Guenther wrote:
> 
> > On Sun, 22 Oct 2006, Richard Guenther wrote:
> > 
> > > On Sun, 22 Oct 2006, Diego Novillo wrote:
> > > 
> > > > Richard Guenther wrote on 10/22/06 09:57:
> > > > 
> > > > > 2006-04-25  Jeff Law  <law@redhat.com>
> > > > >  Richard Guenther  <rguenther@suse.de>
> > > > > 
> > > > >  PR tree-optimization/15911
> > > > >  * tree-vrp.c (extract_code_and_val_from_cond): New function.
> > > > >  (register_edge_assert_for_1): Likewise.
> > > > >  (register_edge_assert_for): Handle &&/&/||/| in conditionals.
> > > > >  (find_conditional_asserts): Adjust for new function signature.
> > > > >  (find_assert_locations): Likewise.
> > > > >  
> > > > Has this changed since May?
> > > 
> > > No, apart from the added documentation of a return value you noticed
> > > back then.
> > > 
> > > > > +       /* We cannot handle float types at all and will ICE in
> > > > > + 	 various ways down from compare_values.  */
> > > > >
> > > > May be not.  This comment still needs fixing.  s/We cannot/VRP does not/ 
> > > >  Not handling float types is done on purpose.
> > > 
> > > Yeah.
> > > 
> > > > If nothing else changed, OK with that fix.
> > 
> > We're ICEing building aermod.f90 from Polyhedron due to this patch -
> > I'm investigating.
> 
> This is what I am testing.

And this is what it ends up.

Bootstrapped and tested on x86_64-unknown-linux-gnu.

Applied as obvious.

Richard.

2006-10-23  Richard Guenther  <rguenther@suse.de>

	* tree-vrp.c (register_edge_assert_for_1): Fix wrong logic
	for TRUTH_NOT_EXPR.  Clarify comments.

	* gfortran.fortran-torture/compile/vrp_1.f90: New testcase.

Index: tree-vrp.c
===================================================================
*** tree-vrp.c	(revision 117967)
--- tree-vrp.c	(working copy)
*************** static bool
*** 2777,2783 ****
  register_edge_assert_for_1 (tree op, enum tree_code code,
  			    edge e, block_stmt_iterator bsi)
  {
!   bool invert, retval = false;
    tree op_def, rhs, val;
  
    /* We only care about SSA_NAMEs.  */
--- 2777,2783 ----
  register_edge_assert_for_1 (tree op, enum tree_code code,
  			    edge e, block_stmt_iterator bsi)
  {
!   bool retval = false;
    tree op_def, rhs, val;
  
    /* We only care about SSA_NAMEs.  */
*************** register_edge_assert_for_1 (tree op, enu
*** 2804,2814 ****
    if (TREE_CODE (op_def) != MODIFY_EXPR)
      return retval;
  
-   invert = (code == EQ_EXPR ? true : false);
    rhs = TREE_OPERAND (op_def, 1);
  
    if (COMPARISON_CLASS_P (rhs))
      {
        tree op0 = TREE_OPERAND (rhs, 0);
        tree op1 = TREE_OPERAND (rhs, 1);
  
--- 2804,2814 ----
    if (TREE_CODE (op_def) != MODIFY_EXPR)
      return retval;
  
    rhs = TREE_OPERAND (op_def, 1);
  
    if (COMPARISON_CLASS_P (rhs))
      {
+       bool invert = (code == EQ_EXPR ? true : false);
        tree op0 = TREE_OPERAND (rhs, 0);
        tree op1 = TREE_OPERAND (rhs, 1);
  
*************** register_edge_assert_for_1 (tree op, enu
*** 2848,2862 ****
      }
    else if (TREE_CODE (rhs) == TRUTH_NOT_EXPR)
      {
!       invert = !invert;
!       /* Recurse, flipping the tense of INVERT.  */
        retval |= register_edge_assert_for_1 (TREE_OPERAND (rhs, 0),
! 					    invert, e, bsi);
      }
    else if (TREE_CODE (rhs) == SSA_NAME)
      {
!       /* Recurse through the copy, the tense of INVERT remains
! 	 unchanged.  */
        retval |= register_edge_assert_for_1 (rhs, code, e, bsi);
      }
    else if (TREE_CODE (rhs) == NOP_EXPR
--- 2848,2861 ----
      }
    else if (TREE_CODE (rhs) == TRUTH_NOT_EXPR)
      {
!       /* Recurse, flipping CODE.  */
!       code = invert_tree_comparison (code, false);
        retval |= register_edge_assert_for_1 (TREE_OPERAND (rhs, 0),
! 					    code, e, bsi);
      }
    else if (TREE_CODE (rhs) == SSA_NAME)
      {
!       /* Recurse through the copy.  */
        retval |= register_edge_assert_for_1 (rhs, code, e, bsi);
      }
    else if (TREE_CODE (rhs) == NOP_EXPR
*************** register_edge_assert_for_1 (tree op, enu
*** 2864,2871 ****
  	   || TREE_CODE (rhs) == VIEW_CONVERT_EXPR
  	   || TREE_CODE (rhs) == NON_LVALUE_EXPR)
      { 
!       /* Recurse through the type conversion, the tense of INVERT 
! 	 remains unchanged.  */
        retval |= register_edge_assert_for_1 (TREE_OPERAND (rhs, 0),
  					    code, e, bsi);
      }
--- 2863,2869 ----
  	   || TREE_CODE (rhs) == VIEW_CONVERT_EXPR
  	   || TREE_CODE (rhs) == NON_LVALUE_EXPR)
      { 
!       /* Recurse through the type conversion.  */
        retval |= register_edge_assert_for_1 (TREE_OPERAND (rhs, 0),
  					    code, e, bsi);
      }

      SUBROUTINE STONUM(STRVAR,LENGTH)
      CHARACTER STRVAR*(*) , CHK
      LOGICAL MEND , NMARK , MMARK , EMARK
      NMARK = .FALSE.
      MMARK = .FALSE.
      DO WHILE ( .NOT.MEND )
            IF ( CHK.GE.'0' .AND. CHK.LE.'9' ) THEN
               IF ( CHK.EQ.'E' ) THEN
                  NMARK = .TRUE.
               ELSEIF ( .NOT.MMARK .AND. CHK.EQ.'*' .AND. .NOT.NMARK )  &
     &                  THEN
                  MMARK = .TRUE.
               ENDIF
            ENDIF
      ENDDO
      END




More information about the Gcc-patches mailing list