i386: Generate strict_low_part QImode insn with high input register
commitb42a09b258c3ed8d1368e0ef0948034dcf0f8ac9
authorUros Bizjak <ubizjak@gmail.com>
Tue, 14 Nov 2023 17:34:43 +0000 (14 18:34 +0100)
committerUros Bizjak <ubizjak@gmail.com>
Tue, 14 Nov 2023 17:36:02 +0000 (14 18:36 +0100)
tree26d989f03087b9733380fbb5181cbac43ca6254e
parentd64b7c82dab4f0aadf239c8382735add33e38586
i386: Generate strict_low_part QImode insn with high input register

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_and (struct S1 a, struct S2 b)
{
  a.val &= b.val;

  return a;
}

compiles with -O2 to:

movl    %esi, %edx
movl    %edi, %eax
movzbl  %dh, %esi
andb    %sil, %al

ANDB could use high register %dh instead of %sil:

movl    %edi, %eax
movl    %esi, %edx
andb    %dh, %al

Patch introduces strict_low_part QImode insn patterns with one of
its input arguments extracted from high register.

PR target/78904

gcc/ChangeLog:

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

gcc/testsuite/ChangeLog:

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