public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/98495] New: X86 _mm_extract_pi16 incorrectly sign extends result
@ 2021-01-01  4:14 foom at fuhm dot net
  2021-01-01 13:06 ` [Bug target/98495] " hjl.tools at gmail dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: foom at fuhm dot net @ 2021-01-01  4:14 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98495
           Summary: X86 _mm_extract_pi16 incorrectly sign extends result
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: foom at fuhm dot net
  Target Milestone: ---

#include <xmmintrin.h>
int test(__m64 a) {
    return _mm_extract_pi16 (a, 0);
}

Compiles to (x86_64 gcc, -O2):
        pextrw  $0, %xmm0, %eax
        cwtl
        ret

Which results in the value being sign-extended from 16-bits to 32-bits.

The intel docs for PEXTRW state that the upper bits are zeroed, and state that
_mm_extract_pi16 is supposed to implement PEXTRW.

So, the expected result is no sign extension:
        pextrw  $0, %xmm0, %eax
        ret


I'd note that this is not a regression due to the new MMX with SSE2 changes --
GCC has had this bug as far back as I can see. It is currently present on trunk
both for the MMX and SSE2 implementations.

Both clang and MSVC zero-extend rather than sign-extend. And, for that matter,
GCC's _mm_extract_epi16 function _also_ zero-extends -- it was fixed in PR45336
for GCC 4.6.

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

* [Bug target/98495] X86 _mm_extract_pi16 incorrectly sign extends result
  2021-01-01  4:14 [Bug target/98495] New: X86 _mm_extract_pi16 incorrectly sign extends result foom at fuhm dot net
@ 2021-01-01 13:06 ` hjl.tools at gmail dot com
  2021-01-01 13:35 ` hjl.tools at gmail dot com
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: hjl.tools at gmail dot com @ 2021-01-01 13:06 UTC (permalink / raw)
  To: gcc-bugs

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

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
                 CC|                            |crazylht at gmail dot com,
                   |                            |hjl.tools at gmail dot com,
                   |                            |wwwhhhyyy333 at gmail dot com
   Last reconfirmed|                            |2021-01-01
             Status|UNCONFIRMED                 |NEW
   Target Milestone|---                         |11.0

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

* [Bug target/98495] X86 _mm_extract_pi16 incorrectly sign extends result
  2021-01-01  4:14 [Bug target/98495] New: X86 _mm_extract_pi16 incorrectly sign extends result foom at fuhm dot net
  2021-01-01 13:06 ` [Bug target/98495] " hjl.tools at gmail dot com
@ 2021-01-01 13:35 ` hjl.tools at gmail dot com
  2021-01-05 13:08 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: hjl.tools at gmail dot com @ 2021-01-01 13:35 UTC (permalink / raw)
  To: gcc-bugs

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

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|                            |https://gcc.gnu.org/piperma
                   |                            |il/gcc-patches/2021-January
                   |                            |/562638.html
           Keywords|                            |patch

--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> ---
A patch is posted at

https://gcc.gnu.org/pipermail/gcc-patches/2021-January/562638.html

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

* [Bug target/98495] X86 _mm_extract_pi16 incorrectly sign extends result
  2021-01-01  4:14 [Bug target/98495] New: X86 _mm_extract_pi16 incorrectly sign extends result foom at fuhm dot net
  2021-01-01 13:06 ` [Bug target/98495] " hjl.tools at gmail dot com
  2021-01-01 13:35 ` hjl.tools at gmail dot com
@ 2021-01-05 13:08 ` cvs-commit at gcc dot gnu.org
  2021-01-05 19:23 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-01-05 13:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by H.J. Lu <hjl@gcc.gnu.org>:

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

commit r11-6464-gaf60b0ec79e9c5d7116122b185e44927aca5aa07
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Jan 1 05:30:34 2021 -0800

    x86: Cast to unsigned short first for _mm_extract_pi16

    _mm_extract_pi16 is intrinsic for pextrw, which should be zero-extended,
    not sign-extended.

    gcc/

            PR target/98495
            * config/i386/xmmintrin.h (_mm_extract_pi16): Cast to unsigned
            short first.

    gcc/testsuite/

            PR target/98495
            * gcc.target/i386/pr98495-1.c: New test.
            * gcc.target/i386/pr98495-2.c: New test.
            * gcc.target/i386/pr98495-3.c: New test.
            * gcc.target/i386/pr98495-4.c: New test.
            * gcc.target/i386/pr98495-5.c: New test.

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

* [Bug target/98495] X86 _mm_extract_pi16 incorrectly sign extends result
  2021-01-01  4:14 [Bug target/98495] New: X86 _mm_extract_pi16 incorrectly sign extends result foom at fuhm dot net
                   ` (2 preceding siblings ...)
  2021-01-05 13:08 ` cvs-commit at gcc dot gnu.org
@ 2021-01-05 19:23 ` cvs-commit at gcc dot gnu.org
  2021-04-27 11:39 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-01-05 19:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by H.J. Lu <hjl@gcc.gnu.org>:

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

commit r11-6484-gf6dd35cf9300ae482038c26655b3cee3e72cefb1
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Jan 5 10:57:20 2021 -0800

    x86: Use unsigned short to compute pextrw result

    Use unsigned short to compute the zero-extended pextrw result.

            PR target/98495
            * gcc.target/i386/sse2-mmx-pextrw.c (compute_correct_result): Use
            unsigned short to compute pextrw result.

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

* [Bug target/98495] X86 _mm_extract_pi16 incorrectly sign extends result
  2021-01-01  4:14 [Bug target/98495] New: X86 _mm_extract_pi16 incorrectly sign extends result foom at fuhm dot net
                   ` (3 preceding siblings ...)
  2021-01-05 19:23 ` cvs-commit at gcc dot gnu.org
@ 2021-04-27 11:39 ` jakub at gcc dot gnu.org
  2021-07-28  7:05 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-04-27 11:39 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|11.0                        |11.2

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 11.1 has been released, retargeting bugs to GCC 11.2.

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

* [Bug target/98495] X86 _mm_extract_pi16 incorrectly sign extends result
  2021-01-01  4:14 [Bug target/98495] New: X86 _mm_extract_pi16 incorrectly sign extends result foom at fuhm dot net
                   ` (4 preceding siblings ...)
  2021-04-27 11:39 ` jakub at gcc dot gnu.org
@ 2021-07-28  7:05 ` rguenth at gcc dot gnu.org
  2022-04-21  7:48 ` rguenth at gcc dot gnu.org
  2023-05-29 10:03 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-28  7:05 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|11.2                        |11.3

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 11.2 is being released, retargeting bugs to GCC 11.3

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

* [Bug target/98495] X86 _mm_extract_pi16 incorrectly sign extends result
  2021-01-01  4:14 [Bug target/98495] New: X86 _mm_extract_pi16 incorrectly sign extends result foom at fuhm dot net
                   ` (5 preceding siblings ...)
  2021-07-28  7:05 ` rguenth at gcc dot gnu.org
@ 2022-04-21  7:48 ` rguenth at gcc dot gnu.org
  2023-05-29 10:03 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-04-21  7:48 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|11.3                        |11.4

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 11.3 is being released, retargeting bugs to GCC 11.4.

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

* [Bug target/98495] X86 _mm_extract_pi16 incorrectly sign extends result
  2021-01-01  4:14 [Bug target/98495] New: X86 _mm_extract_pi16 incorrectly sign extends result foom at fuhm dot net
                   ` (6 preceding siblings ...)
  2022-04-21  7:48 ` rguenth at gcc dot gnu.org
@ 2023-05-29 10:03 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-05-29 10:03 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|11.4                        |11.5

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 11.4 is being released, retargeting bugs to GCC 11.5.

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

end of thread, other threads:[~2023-05-29 10:03 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-01  4:14 [Bug target/98495] New: X86 _mm_extract_pi16 incorrectly sign extends result foom at fuhm dot net
2021-01-01 13:06 ` [Bug target/98495] " hjl.tools at gmail dot com
2021-01-01 13:35 ` hjl.tools at gmail dot com
2021-01-05 13:08 ` cvs-commit at gcc dot gnu.org
2021-01-05 19:23 ` cvs-commit at gcc dot gnu.org
2021-04-27 11:39 ` jakub at gcc dot gnu.org
2021-07-28  7:05 ` rguenth at gcc dot gnu.org
2022-04-21  7:48 ` rguenth at gcc dot gnu.org
2023-05-29 10:03 ` jakub 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).