i386: Relax extract location operand mode requirements [PR108516]
authorUros Bizjak <ubizjak@gmail.com>
Mon, 13 Feb 2023 16:17:46 +0000 (17:17 +0100)
committerUros Bizjak <ubizjak@gmail.com>
Mon, 13 Feb 2023 19:24:02 +0000 (20:24 +0100)
commit00b8a212ea2132fb68e42488317392346e169035
tree5992125499ae81eb4f1720c6b7f0d0abc49d3da1
parent296cf77b78b5c95069a9c07a2919d82438db2fba
i386: Relax extract location operand mode requirements [PR108516]

Combine pass simplifies zero-extend of a zero-extract to:

Trying 16 -> 6:
   16: r86:QI#0=zero_extract(r87:HI,0x8,0x8)
      REG_DEAD r87:HI
    6: r84:SI=zero_extend(r86:QI)
      REG_DEAD r86:QI
Failed to match this instruction:
(set (reg:SI 84 [ s.e2 ])
    (zero_extract:SI (reg:HI 87)
        (const_int 8 [0x8])
        (const_int 8 [0x8])))

which fails instruction recognision.  The pattern is valid, since there
is no requirement on the mode of the location operand.

The patch relaxes location operand mode requirements of *extzv and *extv
insn patterns to allow all supported integer modes.  The patch also
adds support for a related sign-extend from zero-extracted operand.

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

gcc/ChangeLog:

PR target/108516
* config/i386/predicates.md (extr_register_operand):
New special predicate.
* config/i386/i386.md (*extv<mode>): Use extr_register_operand
as operand 1 predicate.
(*exzv<mode>): Ditto.
(*extendqi<SWI24:mode>_ext_1): New insn pattern.

gcc/testsuite/ChangeLog:

PR target/108516
* gcc.target/i386/pr108516-1.c: New test.
* gcc.target/i386/pr108516-2.c: Ditto.
gcc/config/i386/i386.md
gcc/config/i386/predicates.md
gcc/testsuite/gcc.target/i386/pr108516-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr108516-2.c [new file with mode: 0644]