public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/110485] New: vectorizing simd clone calls without loop masking applied
Date: Thu, 29 Jun 2023 12:21:21 +0000	[thread overview]
Message-ID: <bug-110485-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 110485
           Summary: vectorizing simd clone calls without loop masking
                    applied
           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: ---

#include <math.h>

double a[1024];
double b[1024];

void foo (int n)
{
  for (int i = 0; i < n; ++i)
    a[i] = pow (b[i], 71.2);
}

with -Ofast -march=znver4 --param vect-partial-vector-usage=1 gets us
the following OK main loop

.L4:
        vmovapd b(%rbx), %zmm0
        vmovapd -112(%rbp), %zmm1
        addq    $64, %rbx
        call    _ZGVeN8vv_pow
        vmovapd %zmm0, a-64(%rbx)
        cmpq    %r13, %rbx
        jne     .L4

but the following vectorized masked epilogue:

        movl    %r12d, %eax
        andl    $-8, %eax
        testb   $7, %r12b
        je      .L13
.L3:
        subl    %eax, %r12d
        movl    %eax, %edx
        vmovapd -112(%rbp), %zmm1
        vpbroadcastw    %r12d, %xmm0
        leaq    0(,%rdx,8), %rbx
        vpcmpuw $6, .LC2(%rip), %xmm0, %k1
        vmovapd b(,%rdx,8), %zmm0{%k1}{z}
        kmovb   %k1, -113(%rbp)
        call    _ZGVeN8vv_pow
        kmovb   -113(%rbp), %k1
        vmovapd %zmm0, a(%rbx){%k1}

so we simply call _ZGVeN8vv_pow without any masking applied.  That's
possibly OK since we use zero-masking and thus actual masked argument
lanes are zero but it seems this isn't the expected behavior for
vectorizable_simd_clone_call.  Instead it should probably unconditionally
set LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P (loop_vinfo) to false?

Is there a way to query which SIMD clone is "happy" with zero arguments
and thus for example with -ffast-math would be OK to run unmasked?

             reply	other threads:[~2023-06-29 12:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-29 12:21 rguenth at gcc dot gnu.org [this message]
2023-07-02 21:10 ` [Bug tree-optimization/110485] " rsandifo at gcc dot gnu.org
2023-07-03  8:52 ` rguenth at gcc dot gnu.org
2023-10-19 17:31 ` cvs-commit at gcc dot gnu.org
2023-12-05 14:25 ` rguenth at gcc dot gnu.org

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-110485-4@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: link
Be 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).