]> git.ipfire.org Git - thirdparty/gcc.git/commit - gcc/config/pru/constraints.md
PR target/106564: pru: Optimize 64-bit sign- and zero-extend
authorDimitar Dimitrov <dimitar@dinux.eu>
Sun, 14 Aug 2022 15:50:18 +0000 (18:50 +0300)
committerDimitar Dimitrov <dimitar@dinux.eu>
Mon, 22 Aug 2022 19:28:58 +0000 (22:28 +0300)
commit10dd6dea95c5fc41c789c6506338e101e0590a02
tree0b3ae70673e55ab658628ad13e8fb6b3c7eb6ac1
parent7e51df048ae849115e12bf12702bdf1b65893be7
PR target/106564: pru: Optimize 64-bit sign- and zero-extend

Add new patterns to optimize 64-bit sign- and zero-extend operations for
the PRU target.

The new 64-bit zero-extend patterns are straightforward define_insns.

The old 16/32-bit sign-extend pattern has been rewritten from scratch
in order to add 64-bit support.  The new pattern expands into several
optimized insns for filling bytes with zeros or ones, and for
conditional branching on bit-test.  The bulk of this patch is to
implement the patterns for those new optimized insns.

PR target/106564

gcc/ChangeLog:

* config/pru/constraints.md (Um): New constraint for -1.
(Uf): New constraint for IOR fill-bytes constants.
(Uz): New constraint for AND zero-bytes constants.
* config/pru/predicates.md (const_fillbytes_operand): New
predicate for IOR fill-bytes constants.
(const_zerobytes_operand): New predicate for AND zero-bytes
constants.
* config/pru/pru-protos.h (pru_output_sign_extend): Remove.
(struct pru_byterange): New struct to describe a byte range.
(pru_calc_byterange): New declaration.
* config/pru/pru.cc (pru_rtx_costs): Add penalty for
64-bit zero-extend.
(pru_output_sign_extend): Remove.
(pru_calc_byterange): New helper function to extract byte
range info from a constant.
(pru_print_operand): Remove 'y' and 'z' print modifiers.
* config/pru/pru.md (zero_extendqidi2): New pattern.
(zero_extendhidi2): New pattern.
(zero_extendsidi2): New pattern.
(extend<EQS0:mode><EQD:mode>2): Rewrite as an expand.
(@pru_ior_fillbytes<mode>): New pattern.
(@pru_and_zerobytes<mode>): New pattern.
(<code>di3): Rewrite as an expand and handle ZERO and FILL
special cases.
(pru_<code>di3): New name for <code>di3.
(@cbranch_qbbx_const_<BIT_TEST:code><HIDI:mode>): New pattern to
handle bit-test for 64-bit registers.

gcc/testsuite/ChangeLog:

* gcc.target/pru/pr106564-1.c: New test.
* gcc.target/pru/pr106564-2.c: New test.
* gcc.target/pru/pr106564-3.c: New test.
* gcc.target/pru/pr106564-4.c: New test.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
gcc/config/pru/constraints.md
gcc/config/pru/predicates.md
gcc/config/pru/pru-protos.h
gcc/config/pru/pru.cc
gcc/config/pru/pru.md
gcc/testsuite/gcc.target/pru/pr106564-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/pru/pr106564-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/pru/pr106564-3.c [new file with mode: 0644]
gcc/testsuite/gcc.target/pru/pr106564-4.c [new file with mode: 0644]