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 overzealous folding


> Eric, would you please look into this

Already done, please re-read the thread.

> and work out what we really ought to be doing here? 

Already done as well: properly disable the folding or rewrite VRP to avoid 
taking advantage of TYPE_MIN/MAX_VALUE.

> And, would you please add a comment to the code that you changed that
> indicates that the exclusion of ENUMERAL_TYPEs is a work-around, with a
> link to the PR so that we know why?

Here's what I've installed on the mainline.  The exclusion of BOOLEAN_TYPE has 
been there from day #1 apparently.

Index: fold-const.c
===================================================================
--- fold-const.c	(revision 136136)
+++ fold-const.c	(working copy)
@@ -7866,7 +7866,10 @@ fold_unary (enum tree_code code, tree ty
 
       /* Convert (T)(x & c) into (T)x & (T)c, if c is an integer
 	 constants (if x has signed type, the sign bit cannot be set
-	 in c).  This folds extension into the BIT_AND_EXPR.  */
+	 in c).  This folds extension into the BIT_AND_EXPR.
+	 ??? We don't do it for BOOLEAN_TYPE or ENUMERAL_TYPE because they
+	 very likely don't have maximal range for their precision and this
+	 transformation effectively doesn't preserve non-maximal ranges.  */
       if (TREE_CODE (type) == INTEGER_TYPE
 	  && TREE_CODE (op0) == BIT_AND_EXPR
 	  && TREE_CODE (TREE_OPERAND (op0, 1)) == INTEGER_CST)

-- 
Eric Botcazou


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