]> git.ipfire.org Git - thirdparty/gcc.git/commit
i386: Optimize strict_low_part QImode insn with high input registers
authorUros Bizjak <ubizjak@gmail.com>
Wed, 15 Nov 2023 21:21:10 +0000 (22:21 +0100)
committerUros Bizjak <ubizjak@gmail.com>
Wed, 15 Nov 2023 21:22:06 +0000 (22:22 +0100)
commite8676f9ded71f5e04c4e9d81ec656809f6ba54e6
treeef02e2c87330d71a60223b0664d5a7f31cc96847
parent01bc30b222a9d2ff0269325d9e367f8f1fcef942
i386: Optimize strict_low_part QImode insn with high input registers

Following testcase:

struct S1
{
  unsigned char val;
  unsigned char pad1;
  unsigned short pad2;
};

struct S2
{
  unsigned char pad1;
  unsigned char val;
  unsigned short pad2;
};

struct S1 test_add (struct S1 a, struct S2 b, struct S2 c)
{
  a.val = b.val + c.val;

  return a;
}

compiles with -O2 to:

        movl    %edi, %eax
        movzbl  %dh, %edx
        movl    %esi, %ecx
        movb    %dl, %al
        addb    %ch, %al

The insert to %al can go directly from %dh:

        movl    %edi, %eax
        movl    %esi, %ecx
        movb    %dh, %al
        addb    %ch, %al

Patch introduces strict_low_part QImode insn patterns with both of
their input arguments extracted from high register.  This invalid
insn is split after reload to a lowpart insert from the high register
and <insn>qi_ext<mode>_1_slp instruction.

PR target/78904

gcc/ChangeLog:

* config/i386/i386.md (*movstrictqi_ext<mode>_1): New insn pattern.
(*addqi_ext<mode>_2_slp): New define_insn_and_split pattern.
(*subqi_ext<mode>_2_slp): Ditto.
(*<any_logic:code>qi_ext<mode>_2_slp): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr78904-8.c: New test.
* gcc.target/i386/pr78904-8a.c: New test.
* gcc.target/i386/pr78904-8b.c: New test.
* gcc.target/i386/pr78904-9.c: New test.
* gcc.target/i386/pr78904-9a.c: New test.
* gcc.target/i386/pr78904-9b.c: New test.
gcc/config/i386/i386.md
gcc/testsuite/gcc.target/i386/pr78904-8.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr78904-8a.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr78904-8b.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr78904-9.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr78904-9a.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr78904-9b.c [new file with mode: 0644]