[PATCH][PR tree-optimization/69270] Exploit VRP information in DOM
Jakub Jelinek
jakub@redhat.com
Thu Jan 14 07:49:00 GMT 2016
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
More information about the Gcc-patches
mailing list