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]

Re: [patch] Fix two ABS_EXPR regressions


 Hi,

  This is a follow-on to the previous patch which allows ABS_EXPR<ABS_EXPR<x>>
to be folded into ABS_EXPR<x> even if flag_wrapv is turned on.  Bootstrapped
and regtested on ia64-linux with no new regressions.  Ok for mainline.

-- 
Thanks,
Jim

http://www.csclub.uwaterloo.ca/~ja2morri/
http://phython.blogspot.com
http://open.nit.ca/wiki/?page=jim

2005-07-19  James A. Morrison  <phython@gcc.gnu.org>

	* fold-const.c (fold_unary): Always fold ABS_EXPR<ABS_EXPR<x>> into
	ABS_EXPR<x>.

Index: fold-const.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.603
diff -u -p -r1.603 fold-const.c
--- fold-const.c	15 Jul 2005 23:13:54 -0000	1.603
+++ fold-const.c	19 Jul 2005 14:45:12 -0000
@@ -6827,7 +6827,8 @@ fold_unary (enum tree_code code, tree ty
 						    TREE_TYPE (targ0),
 						    targ0));
 	}
-      else if (tree_expr_nonnegative_p (arg0))
+      /* ABS_EXPR<ABS_EXPR<x>> = ABS_EXPR<x> even if flag_wrapv is on.  */
+      else if (tree_expr_nonnegative_p (arg0) || TREE_CODE (arg0) == ABS_EXPR)
 	return arg0;
 
       /* Strip sign ops from argument.  */
/* { dg-do compile } */
/* { dg-options "-fdump-tree-gimple -fwrapv" } */
#define ABS(x) (x > 0 ? x : -x)
int f (int a) {
	return ABS (ABS(a));
}

/* { dg-final { scan-tree-dump-times "ABS" 1 "gimple" } } */
/* { dg-final { cleanup-tree-dump "gimple" } } */

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