diff options
author | Roger Sayle <roger@nextmovesoftware.com> | 2022-02-03 14:46:40 +0100 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2022-02-10 09:01:54 +0100 |
commit | f68c3de7fc9065d8c9ac75b3736ea27abffdce45 (patch) | |
tree | 7e1bdde96877da38500750081c4da6f9a7dccdf2 /gcc/fortran | |
parent | 26d7b8f9bdf9ffb414beaa1133672f2d04c954eb (diff) | |
download | gcc-f68c3de7fc9065d8c9ac75b3736ea27abffdce45.zip gcc-f68c3de7fc9065d8c9ac75b3736ea27abffdce45.tar.gz gcc-f68c3de7fc9065d8c9ac75b3736ea27abffdce45.tar.bz2 |
nvptx: Fix and use BI mode logic instructions (e.g. and.pred)
This patch adds support for nvptx's BImode and.pred, or.pred and
xor.pred instructions. Technically, nvptx.md previously defined
andbi3, iorbi3 and xorbi3 instructions, but the assembly language
mnemonic output for these was incorrect (e.g. and.b1) and would be
rejected by the ptxas assembler. The most significant part of this
patch is the new define_split which teaches the compiler to actually
use these instructions when appropriate (exposing the latent bug above).
After https://gcc.gnu.org/pipermail/gcc-patches/2022-January/587999.html,
the function:
int foo(int x, int y) { return (x==21) && (y==69); }
when compiled with -O2 produces:
mov.u32 %r26, %ar0;
mov.u32 %r27, %ar1;
setp.eq.u32 %r31, %r26, 21;
setp.eq.u32 %r34, %r27, 69;
selp.u32 %r37, 1, 0, %r31;
selp.u32 %r38, 1, 0, %r34;
and.b32 %value, %r37, %r38;
with this patch we now save an extra instruction and generate:
mov.u32 %r26, %ar0;
mov.u32 %r27, %ar1;
setp.eq.u32 %r31, %r26, 21;
setp.eq.u32 %r34, %r27, 69;
and.pred %r39, %r34, %r31;
selp.u32 %value, 1, 0, %r39;
This patch has been tested (on top of the patch mentioned above) on
nvptx-none hosted on x86_64-pc-linux-gnu (including newlib) with a
make and make -k check with no new failures.
gcc/ChangeLog:
* config/nvptx/nvptx.md (any_logic): Move code iterator earlier
in machine description.
(logic): Move code attribute earlier in machine description.
(ilogic): New code attribute, like logic but "ior" for IOR.
(and<mode>3, ior<mode>3, xor<mode>3): Delete. Replace with...
(<ilogic><mode>3): New define_insn for HSDIM logic operations.
(<ilogic>bi3): New define_insn for BI mode logic operations.
(define_split): Lower logic operations from integer modes to
BI mode predicate operations.
gcc/testsuite/ChangeLog:
* gcc.target/nvptx/bool-1.c: Update.
* gcc.target/nvptx/bool-2.c: New test case for and.pred.
* gcc.target/nvptx/bool-3.c: New test case for or.pred.
* gcc.target/nvptx/bool-4.c: New test case for xor.pred.
Diffstat (limited to 'gcc/fortran')
0 files changed, 0 insertions, 0 deletions