public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/111796] New: OMP SIMD call vectorization fails for arguments subject to integer promotion rules
@ 2023-10-13 10:31 rguenth at gcc dot gnu.org
  2023-10-13 12:02 ` [Bug tree-optimization/111796] " rguenth at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-10-13 10:31 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111796
           Summary: OMP SIMD call vectorization fails for arguments
                    subject to integer promotion rules
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
  Target Milestone: ---

For example

int x[1024];

#pragma omp declare simd simdlen(8)
__attribute__((noinline)) int
foo (int a, short b)
{
  return a + b;
}

void __attribute__((noipa))
bar (void)
{
#pragma omp simd
  for (int i = 0; i < 1024; i++)
    x[i] = foo (x[i], x[i]);
}

fails to vetorize because for the scalar code we see

  _4 = x[i_12];
  _5 = (short int) _4;
  _6 = (int) _5;
  _7 = foo (_4, _6);

thus the second argument to 'foo' is promoted to 'int', but the SIMD clone
at least on x86_64 expects vector(8) short int simd.6 as argument.

vectorizable_simd_clone_call has the following, which will result in
rejecting the call.

        for (i = 0; i < nargs; i++)
          {
            switch (n->simdclone->args[i].arg_type)
              {
              case SIMD_CLONE_ARG_TYPE_VECTOR:
                if (!useless_type_conversion_p
                        (n->simdclone->args[i].orig_type,
                         TREE_TYPE (gimple_call_arg (stmt, i + arg_offset))))
                  i = -1;

This argument promotion is exposed by the frontend, controlled by a target
hook.  IIRC it is intended to allow more optimization, so maybe it can be
disabled for calls to OMP SIMD functions.

Alternatively the vectorizer needs to deal with this somehow, for example
in vectorizable_simd_clone_call by allowing this and instead peeking 
through the conversion.  Possibly also done via pattern recognizing the call
itself.

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

end of thread, other threads:[~2023-11-24  2:09 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-13 10:31 [Bug tree-optimization/111796] New: OMP SIMD call vectorization fails for arguments subject to integer promotion rules rguenth at gcc dot gnu.org
2023-10-13 12:02 ` [Bug tree-optimization/111796] " rguenth at gcc dot gnu.org
2023-10-13 12:04 ` rguenth at gcc dot gnu.org
2023-10-13 12:10 ` rguenth at gcc dot gnu.org
2023-10-13 12:16 ` rguenth at gcc dot gnu.org
2023-10-13 12:40 ` rguenth at gcc dot gnu.org
2023-10-13 12:45 ` rguenth at gcc dot gnu.org
2023-11-22  5:21 ` pinskia at gcc dot gnu.org
2023-11-24  2:09 ` pinskia 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).