public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cjashfor at linux dot ibm.com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/94833] New: vec_first_match_index does not function as described in its description
Date: Tue, 28 Apr 2020 20:43:23 +0000	[thread overview]
Message-ID: <bug-94833-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 94833
           Summary: vec_first_match_index does not function as described
                    in its description
           Product: gcc
           Version: 9.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: cjashfor at linux dot ibm.com
                CC: carll at gcc dot gnu.org
  Target Milestone: ---

The description in the 64-bit ELF V2 ABI Specification 1.4 says this:

Purpose:
Performs a comparison of equality on each of the corresponding elements of ARG1
and
ARG2, and returns the first position of equality.
Result value:
Returns the element index of the position of the first character match. If no
match, returns
the number of characters as an element count in the vector argument.


Note that it doesn't make any mention of null or EOS characters.  By the
description, it ought to compare null characters for equality as well, but it
doesn't.  It seems to terminate the comparison when it sees that there's a null
(0x00) in one of the two vector elements.  Here's my test case:

#include <stdio.h>
#include <altivec.h>

int main() {
        vector unsigned char v1 = { 0, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40 };

        vector unsigned char vec_0s = vec_splats((unsigned char)0x0);

        int first_match_index = vec_first_match_index(v1, vec_0s);
        if (first_match_index != 0) {
                printf("Failed: first_match_index should be 0 but it is %d\n",
first_match_index);
        } else {
                printf("Passed\n");
        }
        return 0;
}


I compiled it with -mcpu=power9 -maltivec.  When the test case is run, it says
this:

Failed: first_match_index should be 0 but it is 16

I don't know whether the description is incomplete or the function isn't
implemented correctly.

             reply	other threads:[~2020-04-28 20:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-28 20:43 cjashfor at linux dot ibm.com [this message]
2020-04-28 20:56 ` [Bug c/94833] " cjashfor at linux dot ibm.com
2020-04-28 22:13 ` [Bug target/94833] " carll at gcc dot gnu.org
2020-04-28 22:14 ` carll at gcc dot gnu.org
2020-05-18 17:14 ` cvs-commit at gcc dot gnu.org
2020-06-06 16:46 ` cvs-commit at gcc dot gnu.org
2020-06-10 21:16 ` cvs-commit 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-94833-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).