[PATCH] Fix PR14495 (1/2)

Richard Guenther rguenther@suse.de
Mon Apr 14 09:11:00 GMT 2008


On Mon, 14 Apr 2008, Rafael Espindola wrote:

> >  It also introduces the find_case_label_index helper which will be
> >  needed in (2/2).
> 
> I am trying to port this to tuples and I find it a bit hard to understand.
> 
> You test for the fact that the returned idx is < start_idx. Since all
> assignments to idx are "*idx = i", this is only possible if "i <
> start_idx". "i" is assigned "start_idx" initially and "(high + low)/2"
> in the loop. Since "low >= start_idx - 1", "(high + low)/2 <
> start_idx" is only possible if "high = start_idx and low = start_idx -
> 1". This cannot happen since the loop condition is "high -low > 1".

Quite possible - I more or less copied this routine from
find_case_label_for_value (which didn't exactly suit my needs).
Btw. which check do you exactly mean?  The

  /* Check if we reach the default label only.  */
  if (j < i)
    val = TREE_VEC_ELT (vec, n - 1);

one?  If that cannot be reached then something is either bogus or
missing optimizations.

> Just to make sure I am not getting the math wrong, I added "gcc_assert
> (i >= start_idx)" in all returns. The code is bootstrapping at stage3
> now :-)

Richard.

-- 
Richard Guenther <rguenther@suse.de>
Novell / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746 - GF: Markus Rex



More information about the Gcc-patches mailing list