This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][4.1] Fix PR31940, backport fix for PR26998


This fixes PR31940 on the 4.1 branch.  Bootstrapped and tested on
x86_64-unknown-linux-gnu, applied to the branch.

Richard.


Index: gcc/ChangeLog
===================================================================
*** gcc/ChangeLog	(revision 124766)
--- gcc/ChangeLog	(working copy)
***************
*** 1,3 ****
--- 1,14 ----
+ 2007-05-16  Richard Guenther  <rguenther@suse.de>
+ 
+ 	Backport from mainline:
+ 	2006-06-09  Richard Guenther  <rguenther@suse.de>
+ 
+ 	PR tree-optimization/26998
+ 	* tree-vrp.c (extract_range_from_unary_expr): For NEGATE_EXPR
+ 	of signed types, only TYPE_MIN_VALUE is special, but for both,
+ 	minimum and maximum value.  Likewise VR_ANTI_RANGE is special
+ 	in this case, as is -fwrapv.
+ 
  2007-05-11  Kaz Kojima  <kkojima@gcc.gnu.org>
  
  	PR target/31876
Index: gcc/tree-vrp.c
===================================================================
*** gcc/tree-vrp.c	(revision 124766)
--- gcc/tree-vrp.c	(working copy)
*************** extract_range_from_unary_expr (value_ran
*** 1517,1530 ****
    if (code == NEGATE_EXPR
        && !TYPE_UNSIGNED (TREE_TYPE (expr)))
      {
!       /* NEGATE_EXPR flips the range around.  */
!       min = (vr0.max == TYPE_MAX_VALUE (TREE_TYPE (expr)) && !flag_wrapv)
! 	     ? TYPE_MIN_VALUE (TREE_TYPE (expr))
! 	     : fold_unary_to_constant (code, TREE_TYPE (expr), vr0.max);
! 
!       max = (vr0.min == TYPE_MIN_VALUE (TREE_TYPE (expr)) && !flag_wrapv)
! 	     ? TYPE_MAX_VALUE (TREE_TYPE (expr))
! 	     : fold_unary_to_constant (code, TREE_TYPE (expr), vr0.min);
      }
    else if (code == ABS_EXPR
             && !TYPE_UNSIGNED (TREE_TYPE (expr)))
--- 1517,1537 ----
    if (code == NEGATE_EXPR
        && !TYPE_UNSIGNED (TREE_TYPE (expr)))
      {
!       /* NEGATE_EXPR flips the range around.  We need to treat
! 	 TYPE_MIN_VALUE specially dependent on wrapping, range type
! 	 and if it was used as minimum or maximum value:  
! 	  -~[MIN, MIN] == ~[MIN, MIN]
! 	  -[MIN, 0] == [0, MAX]  for -fno-wrapv
! 	  -[MIN, 0] == [0, MIN]  for -fwrapv (will be set to varying later)  */
!       min = vr0.max == TYPE_MIN_VALUE (TREE_TYPE (expr))
! 	    ? TYPE_MIN_VALUE (TREE_TYPE (expr))
! 	    : fold_unary_to_constant (code, TREE_TYPE (expr), vr0.max);
! 
!       max = vr0.min == TYPE_MIN_VALUE (TREE_TYPE (expr))
! 	    ? (vr0.type == VR_ANTI_RANGE || flag_wrapv
! 	       ? TYPE_MIN_VALUE (TREE_TYPE (expr))
! 	       : TYPE_MAX_VALUE (TREE_TYPE (expr)))
! 	    : fold_unary_to_constant (code, TREE_TYPE (expr), vr0.min);
      }
    else if (code == ABS_EXPR
             && !TYPE_UNSIGNED (TREE_TYPE (expr)))
Index: gcc/testsuite/ChangeLog
===================================================================
*** gcc/testsuite/ChangeLog	(revision 124766)
--- gcc/testsuite/ChangeLog	(working copy)
***************
*** 1,3 ****
--- 1,12 ----
+ 2007-05-16  Richard Guenther  <rguenther@suse.de>
+ 
+ 	Backport from mainline:
+ 	2006-06-09  Richard Guenther  <rguenther@suse.de>
+ 
+ 	PR tree-optimization/26998
+ 	* gcc.dg/torture/pr26998.c: New testcase.
+ 	* gcc.dg/tree-ssa/vrp29.c: New testcase.
+ 
  2007-05-10  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
  
  	PR libfortran/31880


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]