[PATCH] nvptx: Use cvt to perform sign-extension of truncation.
Roger Sayle
roger@nextmovesoftware.com
Fri Aug 27 10:07:18 GMT 2021
This patch introduces some new define_insn rules to the nvptx backend,
to perform sign-extension of a truncation (from and to the same mode),
using a single cvt instruction. As an example, the following function
int foo(int x) { return (char)x; }
with -O2 currently generates:
mov.u32 %r24, %ar0;
mov.u32 %r26, %r24;
cvt.s32.s8 %value, %r26;
and with this patch, now generates:
mov.u32 %r24, %ar0;
cvt.s32.s8 %value, %r24;
This patch has been tested on nvptx-none hosted by x86_64-pc-linux-gnu
with a top-level "make" (including newlib) and a "make check" with no
new regressions. Ok for mainline?
2021-08-27 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
* config/nvptx/nvptx.md (*extend_trunc_<mode>2_qi,
*extend_trunc_<mode>2_hi, *extend_trunc_di2_si): New insns.
Use cvt to perform sign-extension of truncation in one step.
gcc/testsuite/ChangeLog
* gcc.target/nvptx/exttrunc.c: New test case.
Roger
--
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patchz.txt
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20210827/e12aa186/attachment.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: exttrunc.c
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20210827/e12aa186/attachment.c>
More information about the Gcc-patches
mailing list