public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "juzhe.zhong at rivai dot ai" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/113166] RISC-V: Redundant move instructions in RVV intrinsic codes Date: Tue, 30 Jan 2024 11:04:58 +0000 [thread overview] Message-ID: <bug-113166-4-UOrXWqfyFB@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-113166-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113166 --- Comment #3 from JuzheZhong <juzhe.zhong at rivai dot ai> --- #include <cstdint> #include <riscv_vector.h> template <size_t length> inline vuint8m1_t tail_load(void const* data); template<> inline vuint8m1_t tail_load<sizeof(uint64_t)>(void const* data) { uint64_t const* ptr64 = reinterpret_cast<uint64_t const*>(data); #if 1 const vuint64m1_t zero = __riscv_vmv_v_x_u64m1(0, __riscv_vsetvlmax_e64m1()); vuint64m1_t v64 = __riscv_vslide1up(zero, *ptr64, __riscv_vsetvlmax_e64m1()); return __riscv_vreinterpret_u8m1(v64); #elif 1 vuint64m1_t v64 = __riscv_vmv_s_x_u64m1(*ptr64, 1); const vuint64m1_t zero = __riscv_vmv_v_x_u64m1(0, __riscv_vsetvlmax_e64m1()); v64 = __riscv_vslideup(v64, zero, 1, __riscv_vsetvlmax_e8m1()); return __riscv_vreinterpret_u8m1(v64); #elif 1 vuint64m1_t v64 = __riscv_vle64_v_u64m1(ptr64, 1); const vuint64m1_t zero = __riscv_vmv_v_x_u64m1(0, __riscv_vsetvlmax_e64m1()); v64 = __riscv_vslideup(v64, zero, 1, __riscv_vsetvlmax_e8m1()); return __riscv_vreinterpret_u8m1(v64); #else vuint8m1_t v = __riscv_vreinterpret_u8m1(__riscv_vle64_v_u64m1(ptr64, 1)); const vuint8m1_t zero = __riscv_vmv_v_x_u8m1(0, __riscv_vsetvlmax_e8m1()); return __riscv_vslideup(v, zero, sizeof(uint64_t), __riscv_vsetvlmax_e8m1()); #endif } vuint8m1_t test2(uint64_t data) { return tail_load<sizeof(data)>(&data); } GCC ASM: test2(unsigned long): vsetvli a5,zero,e64,m1,ta,ma vmv.v.i v8,0 vmv1r.v v9,v8 vslide1up.vx v8,v9,a0 ret LLVM ASM: test2(unsigned long): # @test2(unsigned long) vsetvli a1, zero, e64, m1, ta, ma vmv.v.i v9, 0 vslide1up.vx v8, v9, a0 ret
prev parent reply other threads:[~2024-01-30 11:05 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-12-28 22:23 [Bug c/113166] New: " juzhe.zhong at rivai dot ai 2023-12-28 22:32 ` [Bug c/113166] " juzhe.zhong at rivai dot ai 2024-01-18 14:06 ` [Bug middle-end/113166] " juzhe.zhong at rivai dot ai 2024-01-30 11:04 ` juzhe.zhong at rivai dot ai [this message]
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-113166-4-UOrXWqfyFB@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).