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] add VRP for bitwise OR and AND: v2


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


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