This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] add VRP for bitwise OR and AND: v2
- From: Denis Vlasenko <vda dot linux at googlemail dot com>
- To: Daniel Berlin <dannyb at google dot com>
- Cc: Håkan Hjort <hakan at jasper-da dot com>, Richard Guenther <richard dot guenther at gmail dot com>, gcc-patches at gcc dot gnu dot org
- Date: Thu, 10 Aug 2006 12:40:04 +0200
- Subject: Re: [PATCH] add VRP for bitwise OR and AND: v2
- References: <200608091936.36366.vda.linux@googlemail.com> <44DA24E4.1010606@google.com>
On Wednesday 09 August 2006 20:09, Daniel Berlin wrote:
> > +static int
> > +integer_nonnegative_range (value_range_t *vr, tree type)
> > +{
> > + if (vr->type == VR_RANGE
> > + && TREE_CODE (vr->min) == INTEGER_CST
> > + && vrp_expr_computes_nonnegative (vr->min)
> > + && TREE_CODE (vr->max) == INTEGER_CST) {
> > + return 1;
> > +}
> > +/* FIXME: does not compile (trips assert)
> > + if (TYPE_UNSIGNED (type))
> > + {
> > + set_value_range_to_nonnegative (vr, type);
> > + return 1;
> > + }
> > +*/
> > + return 0;
>
> Err, you should find out why it asserts. Sounds like it should work at
> first glance.
I think set_value_range_to_nonnegative doesn't like ranges which
cover all possible values for the type. I do not plan to address
this right now, I want to verify that patch works as-is,
and after that I can try to cover more cases (like uncommenting
this part of code).
Immediate TODO is to run patched gcc over this:
int main(int a,int b,int c) {
int r;
if(a<0x0100 || a>0x0101) return 1; // 010x
if(b<0x1000 || b>0x1011) return 1; // 10xx
r = a & b;
if(r>0x0001) BAD1();
r = a | b;
if(r<0x1110) BAD2();
r = a & c;
if(r<0x0100) BAD3();
if(r>0x0101) BAD4();
r = a & (char)c;
if(r>0x0001) BAD5();
r = a | (char)c;
if(r<0x0100) BAD6();
if(r>0x01ff) BAD7();
return 0;
}
All calls to BADn() should be optimized out.
--
vda