public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "enkovich.gnu at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/64691] New: Suboptimal register allocation for bytes comparison on i386
Date: Tue, 20 Jan 2015 15:26:00 -0000	[thread overview]
Message-ID: <bug-64691-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64691

            Bug ID: 64691
           Summary: Suboptimal register allocation for bytes comparison on
                    i386
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: enkovich.gnu at gmail dot com

This problem was actually found in 256.bzip2 benchmark codes compiled by GCC
5.0 on -O2.  There is a small loop with bytes comparison which appeared to be
ineffective because compared values were not allocated on registers allowing
byte access.  That caused additional copies and as a result significant loop
slow down.

Situation may be simulated on a small test if we restrict registers usage.

>cat test.c
void test (unsigned char *p, unsigned char val)
{
  unsigned char tmp1, tmp2;
  int i;

  i = 0;
  tmp1 = p[0];
  while (val != tmp1)
    {
      i++;
      tmp2 = tmp1;
      tmp1  = p[i];
      p[i] = tmp2;
    }
  p[0]= tmp1;
}
>gcc -O2 -m32 -ffixed-ebx test.c -S

Here is a loop:

.L3:
        movzbl  (%eax), %ebp
        movl    %esi, %ecx
        movb    %dl, (%eax)
        addl    $1, %eax
        movl    %ebp, %edx
        cmpb    %dl, %cl
        jne     .L3

We have an extra register copy esi->ecx to perform comparison.

Suppose the easiest way to get better register allocation here would be to
transform QI comparison into SI one to relax register constraints.


             reply	other threads:[~2015-01-20 15:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-20 15:26 enkovich.gnu at gmail dot com [this message]
2015-05-12  9:58 ` [Bug target/64691] " ysrumyan at gmail dot com
2015-05-12 10:01 ` ysrumyan at gmail dot com
2021-12-25  7:59 ` pinskia 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-64691-4@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: link
Be 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).