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

* [Bug c/94833] vec_first_match_index does not function as described in its description
  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 ` cjashfor at linux dot ibm.com
  2020-04-28 22:13 ` [Bug target/94833] " carll at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: cjashfor at linux dot ibm.com @ 2020-04-28 20:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Corey Ashford <cjashfor at linux dot ibm.com> ---
When I look at the disassembly, I see it uses vcmpnezb, but maybe it should use
vcmpneb instead:

        int first_match_index = vec_first_match_index(v1, vec_0s);
    10000504:   07 09 00 10     vcmpnezb v0,v0,v1

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

* [Bug target/94833] vec_first_match_index does not function as described in its description
  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 ` carll at gcc dot gnu.org
  2020-04-28 22:14 ` carll at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: carll at gcc dot gnu.org @ 2020-04-28 22:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Carl Love <carll at gcc dot gnu.org> ---
The ABI has the builtin VEC_FIRST_MATCH_OR_EOS_
INDEX (ARG1, ARG2) which says

Returns the element index of the position of either the first character match
or an end-of-string (EOS) terminator. If no match or terminator, returns the
number of characters as an element count in the vector argument.

So, I do agree the builtin in question should be treating the EOS (null) as any
other number for comparison purposes.

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

* [Bug target/94833] vec_first_match_index does not function as described in its description
  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
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: carll at gcc dot gnu.org @ 2020-04-28 22:14 UTC (permalink / raw)
  To: gcc-bugs

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

Carl Love <carll at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2020-04-28
           Assignee|unassigned at gcc dot gnu.org      |carll at gcc dot gnu.org
     Ever confirmed|0                           |1

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

* [Bug target/94833] vec_first_match_index does not function as described in its description
  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
                   ` (2 preceding siblings ...)
  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
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-05-18 17:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Carl Love <carll@gcc.gnu.org>:

https://gcc.gnu.org/g:24f68831d25bad739a6fe167a58b5b4c0c3cbf9a

commit r11-458-g24f68831d25bad739a6fe167a58b5b4c0c3cbf9a
Author: Carl Love <cel@us.ibm.com>
Date:   Wed Apr 29 10:23:11 2020 -0500

    pr94833, fix vec_first_match_index for nulls

    gcc/ChangeLog

    2020-04-30  Carl Love  <cel@us.ibm.com>

            PR target/94833
            * config/rs6000/vsx.md (define_expand): Fix instruction generation
for
            first_match_index_<mode>.
            * testsuite/gcc.target/powerpc/builtins-8-p9-runnable.c (main): Add
            additional test cases with zero vector elements.

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

* [Bug target/94833] vec_first_match_index does not function as described in its description
  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
                   ` (3 preceding siblings ...)
  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
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-06-06 16:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Carl Love <carll@gcc.gnu.org>:

https://gcc.gnu.org/g:a47259fa7737ff6d4a7def074fb30bc7baef2f86

commit r9-8659-ga47259fa7737ff6d4a7def074fb30bc7baef2f86
Author: Carl Love <cel@us.ibm.com>
Date:   Wed Apr 29 10:23:11 2020 -0500

    pr94833, fix vec_first_match_index for nulls

    Backported patch from mainline.  Updated ChangeLog format
            commit 24f68831d25bad739a6fe167a58b5b4c0c3cbf9a
            Author: Carl Love <cel@us.ibm.com>
            Date:   Wed Apr 29 10:23:11 2020 -0500

    2020-04-30  Carl Love  <cel@us.ibm.com>

    gcc/
            PR target/94833
            * config/rs6000/vsx.md (define_expand): Fix instruction generation
for
            first_match_index_<mode>.

    gcc/testsuite/
            PR target/94833
            * gcc.target/powerpc/builtins-8-p9-runnable.c (main): Add
            additional test cases with zero vector elements.

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

* [Bug target/94833] vec_first_match_index does not function as described in its description
  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
                   ` (4 preceding siblings ...)
  2020-06-06 16:46 ` cvs-commit at gcc dot gnu.org
@ 2020-06-10 21:16 ` cvs-commit at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-06-10 21:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-8 branch has been updated by Carl Love <carll@gcc.gnu.org>:

https://gcc.gnu.org/g:c6dce1d8083a2fdc94be167a2465db7fd837ccae

commit r8-10304-gc6dce1d8083a2fdc94be167a2465db7fd837ccae
Author: Carl Love <cel@us.ibm.com>
Date:   Wed Jun 10 16:12:08 2020 -0500

    pr94833, fix vec_first_match_index for nulls

    Backported patch from mainline.  Updated ChangeLog format
            commit 24f68831d25bad739a6fe167a58b5b4c0c3cbf9a
            Author: Carl Love <cel@us.ibm.com>
            Date:   Wed Apr 29 10:23:11 2020 -0500

            Note the mainlin patch adds tests to the test case in mainline. 
The test
            case does not exist in GCC 8.  Only the functional change in
            gcc/config/rs6000/vsx.md was backported.

    2020-06-10  Carl Love  <cel@us.ibm.com>

    gcc/
            PR target/94833
            * config/rs6000/vsx.md (define_expand): Fix instruction generation
for
            first_match_index_<mode>.

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