This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Speed-up def_builtin_const (ix86_valid_target_attribute)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Martin LiÅka <mliska at suse dot cz>
- Cc: gcc-patches at gcc dot gnu dot org, Jan Hubicka <hubicka at ucw dot cz>
- Date: Fri, 20 Mar 2015 12:24:52 +0100
- Subject: Re: [PATCH] Speed-up def_builtin_const (ix86_valid_target_attribute)
- Authentication-results: sourceware.org; auth=none
- References: <54FE1B94 dot 9080208 at suse dot cz> <20150313044257 dot GB55012 at kam dot mff dot cuni dot cz> <550B3DDC dot 4030408 at suse dot cz> <20150320000959 dot GC48586 at kam dot mff dot cuni dot cz> <550BF765 dot 2070705 at suse dot cz>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Fri, Mar 20, 2015 at 11:33:09AM +0100, Martin LiÅka wrote:
> @@ -30670,6 +30673,20 @@ def_builtin_const (HOST_WIDE_INT mask, const char *name,
> static void
> ix86_add_new_builtins (HOST_WIDE_INT isa)
> {
> + /* Last cached isa value. */
> + static HOST_WIDE_INT last_tested_isa_value = 0;
> +
> + /* We iterate through all defined builtins just if the last tested
> + values is different from ISA and just in case there is any intersection
> + between ISA value and union of all possible configurations.
> + Last condition skips iterations if ISA is changed by the change has
> + empty intersection with defined_isa_values. */
> + if ((isa & defined_isa_values) == 0 || isa == last_tested_isa_value
> + || ((isa ^ last_tested_isa_value) & defined_isa_values) == 0)
> + return;
> +
> + last_tested_isa_value = isa;
Isn't at least the isa == last_tested_isa_value test useless?
I mean, if they are equal, then (isa ^ last_tested_isa_value) is 0
and so the third test is true.
Also, given that the loop does something only for
(ix86_builtins_isa[i].isa & isa) != 0
it means once you call ix86_add_new_builtins with some particular
bit set in the isa, it doesn't make sense to try that bit again.
So, I think it would be better:
1) rename defined_isa_values bitmask to say deferred_isa_values
(as in, isa bits that might still enable any new builtins)
2) in def_builtin, don't or in the mask unconditionally, but only
in the else case - when add_builtin_function is not called
3) in ix86_add_new_builtins, don't add last_tested_isa_value at all, instead
do:
if ((isa & deferred_isa_values) == 0)
return;
deferred_isa_values &= ~isa;
That way, when you actually enable all builtins (either immediately in
def_builtin because it wasn't C/C++-like FE, or because all ISAs were
enabled from the start, or because ix86_add_new_builtins has been already
called with sufficiently full bitmask), deferred_isa_values will be 0 and
you won't do anything in the function any more.
Jakub