aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2024-09-25 13:15:42 +0200
committerRichard Biener <rguenth@gcc.gnu.org>2024-09-25 16:08:27 +0200
commit6efc770a71b7227cdbdc24c947ce1fef10794f4c (patch)
treed717f4e84ce59859768709f5f7728e6579e81f18 /gcc
parent1fea6f82489006cfec3171f77bde8b5ed3527616 (diff)
downloadgcc-6efc770a71b7227cdbdc24c947ce1fef10794f4c.zip
gcc-6efc770a71b7227cdbdc24c947ce1fef10794f4c.tar.gz
gcc-6efc770a71b7227cdbdc24c947ce1fef10794f4c.tar.bz2
Speed up wide_int_storage::operator=(wide_int_storage const&)
wide_int_storage shows up high in the profile for the testcase in PR114855 where the apparent issue is that the conditional jump on 'precision' after the (inlined) memcpy stalls the pipeline due to the data dependence and required store-to-load forwarding. We can add scheduling freedom by instead testing precision as from the source which speeds up the function by 30%. I've applied the same logic to the copy CTOR. * wide-int.h (wide_int_storage::wide_int_storage): Branch on source precision to avoid data dependence on memcpy destination. (wide_int_storage::operator=): Likewise.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/wide-int.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/gcc/wide-int.h b/gcc/wide-int.h
index 64b8bf2..777f017 100644
--- a/gcc/wide-int.h
+++ b/gcc/wide-int.h
@@ -1196,7 +1196,7 @@ inline wide_int_storage::wide_int_storage (const T &x)
inline wide_int_storage::wide_int_storage (const wide_int_storage &x)
{
memcpy (this, &x, sizeof (wide_int_storage));
- if (UNLIKELY (precision > WIDE_INT_MAX_INL_PRECISION))
+ if (UNLIKELY (x.precision > WIDE_INT_MAX_INL_PRECISION))
{
u.valp = XNEWVEC (HOST_WIDE_INT, CEIL (precision, HOST_BITS_PER_WIDE_INT));
memcpy (u.valp, x.u.valp, len * sizeof (HOST_WIDE_INT));
@@ -1219,9 +1219,9 @@ wide_int_storage::operator = (const wide_int_storage &x)
XDELETEVEC (u.valp);
}
memcpy (this, &x, sizeof (wide_int_storage));
- if (UNLIKELY (precision > WIDE_INT_MAX_INL_PRECISION))
+ if (UNLIKELY (x.precision > WIDE_INT_MAX_INL_PRECISION))
{
- u.valp = XNEWVEC (HOST_WIDE_INT, CEIL (precision, HOST_BITS_PER_WIDE_INT));
+ u.valp = XNEWVEC (HOST_WIDE_INT, CEIL (x.precision, HOST_BITS_PER_WIDE_INT));
memcpy (u.valp, x.u.valp, len * sizeof (HOST_WIDE_INT));
}
return *this;