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] Inline handled_component_p


On Thu, 16 Apr 2009, Paolo Bonzini wrote:

> 
> > ! static inline bool
> > ! handled_component_p (const_tree t)
> > ! {
> > !   switch (TREE_CODE (t))
> > !     {
> > !     case BIT_FIELD_REF:
> > !     case COMPONENT_REF:
> > !     case ARRAY_REF:
> > !     case ARRAY_RANGE_REF:
> > !     case VIEW_CONVERT_EXPR:
> > !     case REALPART_EXPR:
> > !     case IMAGPART_EXPR:
> > !       return true;
> > ! 
> > !     default:
> > !       return false;
> > !     }
> > ! }
> 
> Given this, why not use IN_RANGE?

That would make ordering in tree.def a correctness issue.  Why not
let the compiler optimize this?

But I see we switch-convert the above.  Ugh.  Martin, can you
investigate?  Testcase:

typedef enum { a = 5, b = 6, c = 7, d = 8, e = 9 } X;

int h1 (X x)
{
  switch (x) {
  case a:
  case b:
  case c:
  case d:
  case e:
    return 1;
  default:
    return 0;
    }
}

switch conversion should see that the constants are all 1 and simply
substitute that, not generating the lookup table (CCP isn't good
enough to constant propagate from the all-ones array from a variable
index load).

Thanks,
Richard.


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