This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][PR tree-optimization/69270] Exploit VRP information in DOM
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Jeff Law <law at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 14 Jan 2016 08:49:19 +0100
- Subject: Re: [PATCH][PR tree-optimization/69270] Exploit VRP information in DOM
- Authentication-results: sourceware.org; auth=none
- References: <5697508C dot 6050006 at redhat dot com> <20160114074643 dot GX3017 at tucnak dot redhat dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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