public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/97194] New: optimize vector element set/extract at variable position
@ 2020-09-24 14:26 rguenth at gcc dot gnu.org
  2020-09-24 14:27 ` [Bug target/97194] " rguenth at gcc dot gnu.org
                   ` (25 more replies)
  0 siblings, 26 replies; 27+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-09-24 14:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97194

            Bug ID: 97194
           Summary: optimize vector element set/extract at variable
                    position
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
  Target Milestone: ---

#define N 32
typedef int T;
typedef T V __attribute__((vector_size(N)));
V set (V v, int idx, T val)
{
  v[idx] = val;
  return v;
}
T get (V v, int idx)
{
  return v[idx];
}

generates with -mavx2

set:
.LFB0:
        .cfi_startproc
        pushq   %rbp
        .cfi_def_cfa_offset 16
        .cfi_offset 6, -16
        movslq  %edi, %rdi
        movq    %rsp, %rbp
        .cfi_def_cfa_register 6
        andq    $-32, %rsp
        vmovdqa %ymm0, -32(%rsp)
        movl    %esi, -32(%rsp,%rdi,4)
        vmovdqa -32(%rsp), %ymm0
^^^ store forwarding fail
        leave
        .cfi_def_cfa 7, 8
        ret

get:
.LFB1:
        .cfi_startproc
        pushq   %rbp
        .cfi_def_cfa_offset 16
        .cfi_offset 6, -16
        movslq  %edi, %rdi
        movq    %rsp, %rbp
        .cfi_def_cfa_register 6
        andq    $-32, %rsp
        vmovdqa %ymm0, -32(%rsp)
        movl    -32(%rsp,%rdi,4), %eax
        leave
        .cfi_def_cfa 7, 8
        ret

maybe not too bad.

Vary N and T to cover all types and vector sizes.

It should be possible to do the 'get' case via variable permutes
and the 'set' case via a splat of the value and a blend using
a mask generated from 'idx'.

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2022-01-11 12:05 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-24 14:26 [Bug target/97194] New: optimize vector element set/extract at variable position rguenth at gcc dot gnu.org
2020-09-24 14:27 ` [Bug target/97194] " rguenth at gcc dot gnu.org
2020-09-24 14:39 ` rguenth at gcc dot gnu.org
2020-09-24 14:52 ` rguenth at gcc dot gnu.org
2020-09-25  6:47 ` rguenth at gcc dot gnu.org
2020-09-27  9:27 ` crazylht at gmail dot com
2020-09-28  7:01 ` rguenth at gcc dot gnu.org
2020-09-28  8:55 ` amonakov at gcc dot gnu.org
2020-09-28  9:20 ` rguenth at gcc dot gnu.org
2020-09-28 10:45 ` amonakov at gcc dot gnu.org
2020-09-28 11:10 ` rguenther at suse dot de
2020-09-28 11:19 ` amonakov at gcc dot gnu.org
2020-09-28 11:42 ` rguenth at gcc dot gnu.org
2020-09-28 11:44 ` rguenth at gcc dot gnu.org
2020-09-28 13:20 ` amonakov at gcc dot gnu.org
2020-10-16  7:17 ` crazylht at gmail dot com
2020-10-16  7:23 ` crazylht at gmail dot com
2020-10-16  7:31 ` rguenth at gcc dot gnu.org
2020-10-16  7:32 ` rguenth at gcc dot gnu.org
2020-10-16  7:46 ` crazylht at gmail dot com
2020-10-16  7:49 ` crazylht at gmail dot com
2020-10-16  8:03 ` rguenther at suse dot de
2020-11-17  3:31 ` cvs-commit at gcc dot gnu.org
2020-11-17  3:39 ` crazylht at gmail dot com
2021-06-17 13:20 ` cvs-commit at gcc dot gnu.org
2021-07-06 17:28 ` cvs-commit at gcc dot gnu.org
2022-01-11 12:05 ` rguenth at gcc dot gnu.org

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).