public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/55278] [4.8/4.9 Regression] Botan performance regressions apparently due to LRA Date: Tue, 07 May 2013 22:34:00 -0000 [thread overview] Message-ID: <bug-55278-4-ubxBY28KPn@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-55278-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55278 --- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-05-07 22:34:15 UTC --- To: unsigned char KASUMI_SBOX_S7[128]; unsigned short KASUMI_SBOX_S9[512]; static inline unsigned short rotate_left (unsigned short input, unsigned long rot) { return ((input << rot) | (input >> (8 * sizeof (unsigned short) - rot))); } static inline unsigned short reverse_bytes (unsigned short val) { return rotate_left (val, 8); } static inline unsigned short load_be (const unsigned char in[], unsigned long off) { return reverse_bytes (*((const unsigned short *)in + off)); } static inline void store_be (unsigned short in, unsigned char out[2]) { *(unsigned short *)out = reverse_bytes (in); } static inline void store_be4 (unsigned char out[], unsigned short x0, unsigned short x1, unsigned short x2, unsigned short x3) { store_be (x0, out + (0 * sizeof (unsigned short))); store_be (x1, out + (1 * sizeof (unsigned short))); store_be (x2, out + (2 * sizeof (unsigned short))); store_be (x3, out + (3 * sizeof (unsigned short))); } unsigned short FI (unsigned short I, unsigned short K) { unsigned short D9 = (I >> 7); unsigned char D7 = (I & 0x7F); D9 = KASUMI_SBOX_S9[D9] ^ D7; D7 = KASUMI_SBOX_S7[D7] ^ (D9 & 0x7F); D7 ^= (K >> 9); D9 = KASUMI_SBOX_S9[D9 ^ (K & 0x1FF)] ^ D7; D7 = KASUMI_SBOX_S7[D7] ^ (D9 & 0x7F); return (D7 << 9) | D9; } __attribute__((noinline, noclone)) void encrypt_n (unsigned short **EK, const unsigned char in[], unsigned char out[], unsigned long blocks) { unsigned long i, j; for (i = 0; i != blocks; ++i) { unsigned short B0 = load_be (in, 0); unsigned short B1 = load_be (in, 1); unsigned short B2 = load_be (in, 2); unsigned short B3 = load_be (in, 3); for (j = 0; j != 8; j += 2) { const unsigned short *K = &(*EK)[8 * j]; unsigned short R = B1 ^ (rotate_left (B0, 1) & K[0]); unsigned short L = B0 ^ (rotate_left (R, 1) | K[1]); L = FI (L ^ K[2], K[3]) ^ R; R = FI (R ^ K[4], K[5]) ^ L; L = FI (L ^ K[6], K[7]) ^ R; R = B2 ^= R; L = B3 ^= L; R = FI (R ^ K[10], K[11]) ^ L; L = FI (L ^ K[12], K[13]) ^ R; R = FI (R ^ K[14], K[15]) ^ L; R ^= (rotate_left (L, 1) & K[8]); L ^= (rotate_left (R, 1) | K[9]); B0 ^= L; B1 ^= R; } store_be4 (out, B0, B1, B2, B3); in += 8; out += 8; } } unsigned char in[4096], out[4096]; int main () { unsigned short EKb[64], *EK = EKb; __builtin_memset (EKb, 0, sizeof EKb); asm volatile ("" : : : "memory"); int i; for (i = 0; i < 100000; i++) encrypt_n (&EK, in, out, 4096 / 8); return 0; } actually (note different code in store_be and load_be). I'm surprised that the 16-bit rotations aren't detected/folded into rotations (or rotate_left (u16, 8) into a bswap16).
next prev parent reply other threads:[~2013-05-07 22:34 UTC|newest] Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-11-11 23:54 [Bug rtl-optimization/55278] New: " hubicka at gcc dot gnu.org 2013-03-23 19:38 ` [Bug rtl-optimization/55278] [4.8 Regression] " steven at gcc dot gnu.org 2013-03-25 10:21 ` [Bug rtl-optimization/55278] [4.8/4.9 " rguenth at gcc dot gnu.org 2013-03-25 11:03 ` hubicka at gcc dot gnu.org 2013-05-07 22:31 ` mpolacek at gcc dot gnu.org 2013-05-07 22:31 ` mpolacek at gcc dot gnu.org 2013-05-07 22:34 ` jakub at gcc dot gnu.org [this message] 2013-05-07 22:48 ` glisse at gcc dot gnu.org 2013-05-08 6:58 ` jakub at gcc dot gnu.org 2013-05-09 13:59 ` jakub at gcc dot gnu.org 2013-05-09 20:35 ` vmakarov at redhat dot com 2013-05-12 17:36 ` [Bug rtl-optimization/55278] [4.8/4.9 Regression] Botan performance regressions, other compilers generate better code than gcc ubizjak at gmail dot com 2013-05-31 11:01 ` jakub at gcc dot gnu.org 2013-10-16 9:49 ` jakub at gcc dot gnu.org 2014-05-22 9:06 ` [Bug rtl-optimization/55278] [4.8/4.9/4.10 " rguenth at gcc dot gnu.org 2014-12-19 13:28 ` [Bug rtl-optimization/55278] [4.8/4.9/5 " jakub at gcc dot gnu.org 2015-06-23 8:21 ` [Bug rtl-optimization/55278] [4.8/4.9/5/6 " rguenth at gcc dot gnu.org 2015-06-26 19:57 ` [Bug rtl-optimization/55278] [4.9/5/6 " jakub at gcc dot gnu.org 2015-06-26 20:29 ` jakub at gcc dot gnu.org 2021-05-14 9:46 ` [Bug rtl-optimization/55278] [9/10/11/12 " jakub at gcc dot gnu.org 2021-06-01 8:05 ` rguenth at gcc dot gnu.org 2021-07-08 18:00 ` ubizjak at gmail dot com 2022-05-27 9:34 ` [Bug rtl-optimization/55278] [10/11/12/13 " rguenth at gcc dot gnu.org 2022-06-15 7:32 ` cvs-commit at gcc dot gnu.org 2022-06-28 10:30 ` jakub at gcc dot gnu.org 2023-03-16 0:05 ` pinskia at gcc dot gnu.org 2023-07-07 10:29 ` [Bug rtl-optimization/55278] [11/12/13/14 " rguenth at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-55278-4-ubxBY28KPn@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).