* [PATCH] Speedup copy_reference_ops_from_ref
@ 2010-12-08 14:57 Richard Guenther
2010-12-08 15:27 ` Joseph S. Myers
0 siblings, 1 reply; 3+ messages in thread
From: Richard Guenther @ 2010-12-08 14:57 UTC (permalink / raw)
To: gcc-patches
This halves the time spent in copy_reference_ops_from_ref for infcodes.c.
The trick is to use a shift when dividing/multiplying by BITS_PER_UNIT
as done elsewhere.
I'll apply this after bootstrapping and testing on
x86_64-unknown-linux-gnu.
Thanks,
Richard.
2010-12-08 Richard Guenther <rguenther@suse.de>
* tree-ssa-sccvn.c (copy_reference_ops_from_ref): Use a shift
instead of a division to divide by BITS_PER_UNIT.
Index: gcc/tree-ssa-sccvn.c
===================================================================
--- gcc/tree-ssa-sccvn.c (revision 167583)
+++ gcc/tree-ssa-sccvn.c (working copy)
@@ -644,10 +644,11 @@ copy_reference_ops_from_ref (tree ref, V
{
double_int off
= double_int_add (tree_to_double_int (this_offset),
- double_int_sdiv
+ double_int_rshift
(tree_to_double_int (bit_offset),
- uhwi_to_double_int (BITS_PER_UNIT),
- TRUNC_DIV_EXPR));
+ BITS_PER_UNIT == 8
+ ? 3 : exact_log2 (BITS_PER_UNIT),
+ HOST_BITS_PER_DOUBLE_INT, true));
if (double_int_fits_in_shwi_p (off))
temp.off = off.low;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Speedup copy_reference_ops_from_ref
2010-12-08 14:57 [PATCH] Speedup copy_reference_ops_from_ref Richard Guenther
@ 2010-12-08 15:27 ` Joseph S. Myers
2010-12-08 15:42 ` Richard Guenther
0 siblings, 1 reply; 3+ messages in thread
From: Joseph S. Myers @ 2010-12-08 15:27 UTC (permalink / raw)
To: Richard Guenther; +Cc: gcc-patches
On Wed, 8 Dec 2010, Richard Guenther wrote:
> + BITS_PER_UNIT == 8
> + ? 3 : exact_log2 (BITS_PER_UNIT),
I know we use this idiom elsewhere, but if we (i.e. 3.4-or-later host
compiler) aren't folding exact_log2 (BITS_PER_UNIT) to a constant (given
constant BITS_PER_UNIT) there's something wrong with either our constant
folding for built-in functions or our inlining heuristics.
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Speedup copy_reference_ops_from_ref
2010-12-08 15:27 ` Joseph S. Myers
@ 2010-12-08 15:42 ` Richard Guenther
0 siblings, 0 replies; 3+ messages in thread
From: Richard Guenther @ 2010-12-08 15:42 UTC (permalink / raw)
To: Joseph S. Myers; +Cc: gcc-patches
On Wed, 8 Dec 2010, Joseph S. Myers wrote:
> On Wed, 8 Dec 2010, Richard Guenther wrote:
>
> > + BITS_PER_UNIT == 8
> > + ? 3 : exact_log2 (BITS_PER_UNIT),
>
> I know we use this idiom elsewhere, but if we (i.e. 3.4-or-later host
> compiler) aren't folding exact_log2 (BITS_PER_UNIT) to a constant (given
> constant BITS_PER_UNIT) there's something wrong with either our constant
> folding for built-in functions or our inlining heuristics.
I think we indeed should fold it to a constant. An even better
cleanup would be to introduce double_int_units_to_bits,
double_int_bits_to_units.
Richard.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-12-08 15:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-08 14:57 [PATCH] Speedup copy_reference_ops_from_ref Richard Guenther
2010-12-08 15:27 ` Joseph S. Myers
2010-12-08 15:42 ` Richard Guenther
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).