This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/19923] [4.0/4.1 Regression] openssl is slower when compiled with gcc 4.0 than 3.3
- From: "dann at godzilla dot ics dot uci dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 24 Jun 2005 17:41:45 -0000
- Subject: [Bug target/19923] [4.0/4.1 Regression] openssl is slower when compiled with gcc 4.0 than 3.3
- References: <20050212153001.19923.gj@pointblue.com.pl>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From dann at godzilla dot ics dot uci dot edu 2005-06-24 17:41 -------
(In reply to comment #21)
> The slow routine appears to be the buffer cleaning routine,
> though I haven't verified this with oprofile yet.
> Here's its loop:
> static char cleanse_ctr;
> ...
> while (len--) {
> *(ptr++) = cleanse_ctr;
> cleanse_ctr += (17 + (unsigned char) ((int) ptr & 0xF));
> }
[Not entirely related, but..] There's one obvious way to improve this loop.
The compiler cannot prove that the write *(ptr++) does not alias the global
variable cleanse_ptr, so it will read it from memory in each iteration.
To avoid the extra memory read just do something like:
void OPENSSL_cleanse(unsigned char *ptr, unsigned int len)
{
unsigned char local_cleanse_ctr = cleanse_ctr;
while (len--) {
*(ptr++) = local_cleanse_ctr;
local_cleanse_ctr += (17 + (unsigned char) ((int) ptr & 0xF));
}
local_cleanse_ctr += 63;
cleanse_ctr = local_cleanse_ctr;
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19923