public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/94833] New: vec_first_match_index does not function as described in its description
@ 2020-04-28 20:43 cjashfor at linux dot ibm.com
  2020-04-28 20:56 ` [Bug c/94833] " cjashfor at linux dot ibm.com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: cjashfor at linux dot ibm.com @ 2020-04-28 20:43 UTC (permalink / raw)
  To: gcc-bugs

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.

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

end of thread, other threads:[~2020-06-10 21:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-28 20:43 [Bug c/94833] New: vec_first_match_index does not function as described in its description cjashfor at linux dot ibm.com
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

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