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][PR tree-optimization/69270] Exploit VRP information in DOM


On Thu, Jan 14, 2016 at 08:46:43AM +0100, Jakub Jelinek wrote:
> On Thu, Jan 14, 2016 at 12:38:52AM -0700, Jeff Law wrote:
> > +  /* An integral type with more precision, but the object
> > +     only takes on values [0..1] as determined by VRP
> > +     analysis.  */
> > +  wide_int min, max;
> > +  if (INTEGRAL_TYPE_P (TREE_TYPE (op))
> > +      && get_range_info (op, &min, &max) == VR_RANGE
> > +      && wi::eq_p (min, 0)
> > +      && wi::eq_p (max, 1))
> > +    return true;
> 
> You could use and/or:
>   if (INTEGRAL_TYPE_P (TREE_TYPE (op)) && wi::eq_p (get_nonzero_bits (op), 1))
> set_range_info for VR_RANGE should usually update also the non-zero bits, but
> set_nonzero_bits does not update the recorded range.

Though, that would need to be limited to TYPE_PRECISION (TREE_TYPE (op)) > 1
or TYPE_UNSIGNED.

BTW,

+  /* An integral type with a single bit of precision.  */                                                                                         
+  if (INTEGRAL_TYPE_P (TREE_TYPE (op))                                                                                                            
+      && TYPE_PRECISION (TREE_TYPE (op)) == 1)                                                                                                    
+    return true;                                                                                                                                  

does not guarantee values 0, 1, it can mean either 0, 1 or -1, 0.  So, if
-1, 0 is unacceptable, you need to use TYPE_UNSIGNED (TREE_TYPE (op)) too.

	Jakub


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