This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: [PATCH] More speedups, this time in build_trtable
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Paolo Bonzini <paolo dot bonzini at polimi dot it>
- Cc: libc-alpha at sources dot redhat dot com
- Date: Tue, 16 Dec 2003 13:41:27 +0100
- Subject: Re: [PATCH] More speedups, this time in build_trtable
- References: <000e01c3c3e1$fb5d27b0$8a41af83@kingkong>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Tue, Dec 16, 2003 at 03:36:13PM +0100, Paolo Bonzini wrote:
> > Perhaps it would be enough if just
> > group_nodes_into_DFAstates never created empty dests_ch[]
> > bitsets.
>
> Does it? There are three places where it sets a dests_ch. New items are
> set from "remains", and old items can be changed to "intersec", but these
> two are done only if both of "not_subset" (the OR of all the items in
> "remains") and "has_intersec" (the OR of all items in INTERSEC) are
> non-zero. So the main for loop never makes zero dests_ch bitsets.
>
> The third bitset_copy is from "accepts" if j == ndests, but this implies
> that "not_consumed" (the OR of all the items in "accepts" is non-zero,
> otherwise it would have done a "break" out of the loop and j would have been
> < ndests. So this seems non-zero to me as well; but maybe I'm missing
> something in the code.
E.g. if state->nodes.elems[0] is SIMPLE_BRACKET [abc] with
NEXT_NOTWORD_CONSTRAINT bit set in constraint, it sets 'a', 'b' and 'c'
in accepts, then it clears it again, ndests == 0 which means it goes zero
times through the following loop and:
if (j == ndests)
{
bitset_copy (dests_ch[ndests], accepts);
err = re_node_set_init_1 (dests_node + ndests, cur_nodes->elems[i]);
if (BE (err != REG_NOERROR, 0))
goto error_return;
++ndests;
bitset_empty (accepts);
}
so dests_ch[ndests] is empty.
I think something like:
if (constraint & NEXT_WORD_CONSTRAINT)
{
unsigned int any_set = 0;
#ifdef RE_ENABLE_I18N
if (dfa->mb_cur_max > 1)
for (j = 0; j < BITSET_UINTS; ++j)
any_set |= accepts[j] &= (dfa->word_char[j] | ~dfa->sb_char[j]);
else
#endif
for (j = 0; j < BITSET_UINTS; ++j)
any_set |= accepts[j] &= dfa->word_char[j];
if (!any_set)
continue;
}
if (constraint & NEXT_NOTWORD_CONSTRAINT)
{
unsigned int any_set = 0;
#ifdef RE_ENABLE_I18N
if (dfa->mb_cur_max > 1)
for (j = 0; j < BITSET_UINTS; ++j)
any_set |= accepts[j] &= ~(dfa->word_char[j] & dfa->sb_char[j]);
else
#endif
for (j = 0; j < BITSET_UINTS; ++j)
any_set |= accepts[j] &= ~dfa->word_char[j];
if (!any_set)
continue;
}
should do the job.
Jakub