public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/108831] New: QImode binary ops with one zero-extracted argument can be optimized
@ 2023-02-17  9:26 ubizjak at gmail dot com
  2023-02-17  9:30 ` [Bug target/108831] " ubizjak at gmail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: ubizjak at gmail dot com @ 2023-02-17  9:26 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108831
           Summary: QImode binary ops with one zero-extracted argument can
                    be optimized
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ubizjak at gmail dot com
  Target Milestone: ---

Following testcase:

--cut here--
struct S
{
  unsigned char pad1;
  unsigned char val;
  unsigned short pad2;
};

unsigned char
test_add (unsigned char a, struct S b)
{
  a += b.val;

  return a;
}
--cut here--

should be compiled to something like:

        addb %dh, %al

but is currently compiled to:

        movzbl  %dh, %edx
        addl    %edx, %eax

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug target/108831] QImode binary ops with one zero-extracted argument can be optimized
  2023-02-17  9:26 [Bug target/108831] New: QImode binary ops with one zero-extracted argument can be optimized ubizjak at gmail dot com
@ 2023-02-17  9:30 ` ubizjak at gmail dot com
  2023-02-17  9:53 ` ubizjak at gmail dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: ubizjak at gmail dot com @ 2023-02-17  9:30 UTC (permalink / raw)
  To: gcc-bugs

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

Uroš Bizjak <ubizjak at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
           Assignee|unassigned at gcc dot gnu.org      |ubizjak at gmail dot com
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2023-02-17

--- Comment #1 from Uroš Bizjak <ubizjak at gmail dot com> ---
Created attachment 54479
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54479&action=edit
Proposed patch

The patch also handles constant memory operands on x86_64.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug target/108831] QImode binary ops with one zero-extracted argument can be optimized
  2023-02-17  9:26 [Bug target/108831] New: QImode binary ops with one zero-extracted argument can be optimized ubizjak at gmail dot com
  2023-02-17  9:30 ` [Bug target/108831] " ubizjak at gmail dot com
@ 2023-02-17  9:53 ` ubizjak at gmail dot com
  2023-02-17 16:49 ` cvs-commit at gcc dot gnu.org
  2023-02-17 16:52 ` ubizjak at gmail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: ubizjak at gmail dot com @ 2023-02-17  9:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to Uroš Bizjak from comment #1)
> The patch also handles constant memory operands on x86_64.

--cut here--
struct S
{
  unsigned char pad1;
  unsigned char val;
  unsigned short pad2;
};

unsigned char a;

void
test_and (struct S b)
{
  a &= b.val;
}
--cut here--

compiles to:

        andb    %ah, a(%rip)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug target/108831] QImode binary ops with one zero-extracted argument can be optimized
  2023-02-17  9:26 [Bug target/108831] New: QImode binary ops with one zero-extracted argument can be optimized ubizjak at gmail dot com
  2023-02-17  9:30 ` [Bug target/108831] " ubizjak at gmail dot com
  2023-02-17  9:53 ` ubizjak at gmail dot com
@ 2023-02-17 16:49 ` cvs-commit at gcc dot gnu.org
  2023-02-17 16:52 ` ubizjak at gmail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-02-17 16:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Uros Bizjak <uros@gcc.gnu.org>:

https://gcc.gnu.org/g:6245441e124846d0c3551f312d2feef598fe251c

commit r13-6118-g6245441e124846d0c3551f312d2feef598fe251c
Author: Uros Bizjak <ubizjak@gmail.com>
Date:   Fri Feb 17 17:00:12 2023 +0100

    ii386: Generate QImode binary ops with high-part input register [PR108831]

    Following testcase:

    --cut here--
    struct S
    {
      unsigned char pad1;
      unsigned char val;
      unsigned short pad2;
    };

    unsigned char
    test_add (unsigned char a, struct S b)
    {
      a += b.val;

      return a;
    }
    --cut here--

    should be compiled to something like:

            addb %dh, %al

    but is currently compiled to:

            movzbl  %dh, %edx
            addl    %edx, %eax

    The patch implements insn patterns that model QImode binary ops with
    high-part QImode input register.  These ops can not be encoded with
    REX prefix, so only Q registers and constant memory output operands
    are allowed on x86_64 targets.

    2023-02-17  Uroš Bizjak  <ubizjak@gmail.com>

    gcc/ChangeLog:

            PR target/108831
            * config/i386/predicates.md
            (nonimm_x64constmem_operand): New predicate.
            * config/i386/i386.md (*addqi_ext<mode>_0): New insn pattern.
            (*subqi_ext<mode>_0): Ditto.
            (*andqi_ext<mode>_0): Ditto.
            (*<any_or:code>qi_ext<mode>_0): Ditto.

    gcc/testsuite/ChangeLog:

            PR target/108831
            * gcc.target/i386/pr108831-1.c: New test.
            * gcc.target/i386/pr108831-2.c: Ditto.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug target/108831] QImode binary ops with one zero-extracted argument can be optimized
  2023-02-17  9:26 [Bug target/108831] New: QImode binary ops with one zero-extracted argument can be optimized ubizjak at gmail dot com
                   ` (2 preceding siblings ...)
  2023-02-17 16:49 ` cvs-commit at gcc dot gnu.org
@ 2023-02-17 16:52 ` ubizjak at gmail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: ubizjak at gmail dot com @ 2023-02-17 16:52 UTC (permalink / raw)
  To: gcc-bugs

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

Uroš Bizjak <ubizjak at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
   Target Milestone|---                         |13.0
             Status|ASSIGNED                    |RESOLVED

--- Comment #4 from Uroš Bizjak <ubizjak at gmail dot com> ---
Implemented for gcc-13.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-02-17 16:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-17  9:26 [Bug target/108831] New: QImode binary ops with one zero-extracted argument can be optimized ubizjak at gmail dot com
2023-02-17  9:30 ` [Bug target/108831] " ubizjak at gmail dot com
2023-02-17  9:53 ` ubizjak at gmail dot com
2023-02-17 16:49 ` cvs-commit at gcc dot gnu.org
2023-02-17 16:52 ` ubizjak at gmail dot com

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).