Message ID | 20201027224857.GD25210@kam.mff.cuni.cz |
---|---|
State | New |
Headers | show |
Series | Avoid typeless storage in trailing wide ints | expand |
On Tue, Oct 27, 2020 at 11:49 PM Jan Hubicka <hubicka@ucw.cz> wrote: > > Hi, > this patch avoid typeless storage in trailing_wide_ints. This improves > TBAA disambiguation rate on cc1plus by 7%. > > Bootstrapped/regtested x86_64-linux, OK? OK. I guess if uint8_t would be a separate type from unsigned char that would work as well but it is not. Thanks, Richard. > * wide-int.h (trailing_wide_ints <N>): Turn len to array of structures > so it does not imply typeless storage. > (trailing_wide_ints <N>::operator): update > (trailing_wide_ints <N>::operator []): Update. > diff --git a/gcc/wide-int.h b/gcc/wide-int.h > index 39cd5b9bd17..6eae46da12e 100644 > --- a/gcc/wide-int.h > +++ b/gcc/wide-int.h > @@ -1387,8 +1387,10 @@ private: > /* The shared maximum length of each number. */ > unsigned char m_max_len; > > - /* The current length of each number. */ > - unsigned char m_len[N]; > + /* The current length of each number. > + Avoid char array so the whole structure is not a typeless storage > + that will, in turn, turn off TBAA on gimple, trees and RTL. */ > + struct {unsigned char len;} m_len[N]; > > /* The variable-length part of the structure, which always contains > at least one HWI. Element I starts at index I * M_MAX_LEN. */ > @@ -1470,7 +1472,7 @@ template <int N> > inline trailing_wide_int > trailing_wide_ints <N>::operator [] (unsigned int index) > { > - return trailing_wide_int_storage (m_precision, &m_len[index], > + return trailing_wide_int_storage (m_precision, &m_len[index].len, > &m_val[index * m_max_len]); > } > > @@ -1479,7 +1481,7 @@ inline typename trailing_wide_ints <N>::const_reference > trailing_wide_ints <N>::operator [] (unsigned int index) const > { > return wi::storage_ref (&m_val[index * m_max_len], > - m_len[index], m_precision); > + m_len[index].len, m_precision); > } > > /* Return how many extra bytes need to be added to the end of the structure
diff --git a/gcc/wide-int.h b/gcc/wide-int.h index 39cd5b9bd17..6eae46da12e 100644 --- a/gcc/wide-int.h +++ b/gcc/wide-int.h @@ -1387,8 +1387,10 @@ private: /* The shared maximum length of each number. */ unsigned char m_max_len; - /* The current length of each number. */ - unsigned char m_len[N]; + /* The current length of each number. + Avoid char array so the whole structure is not a typeless storage + that will, in turn, turn off TBAA on gimple, trees and RTL. */ + struct {unsigned char len;} m_len[N]; /* The variable-length part of the structure, which always contains at least one HWI. Element I starts at index I * M_MAX_LEN. */ @@ -1470,7 +1472,7 @@ template <int N> inline trailing_wide_int trailing_wide_ints <N>::operator [] (unsigned int index) { - return trailing_wide_int_storage (m_precision, &m_len[index], + return trailing_wide_int_storage (m_precision, &m_len[index].len, &m_val[index * m_max_len]); } @@ -1479,7 +1481,7 @@ inline typename trailing_wide_ints <N>::const_reference trailing_wide_ints <N>::operator [] (unsigned int index) const { return wi::storage_ref (&m_val[index * m_max_len], - m_len[index], m_precision); + m_len[index].len, m_precision); } /* Return how many extra bytes need to be added to the end of the structure