public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/102583] New: [x86] Failure to optimize 32-byte integer vector conversion to 16-byte float vector properly when converting upper part with -mavx2
@ 2021-10-04  2:57 gabravier at gmail dot com
  2021-10-04  7:53 ` [Bug target/102583] " rguenth at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: gabravier at gmail dot com @ 2021-10-04  2:57 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102583
           Summary: [x86] Failure to optimize 32-byte integer vector
                    conversion to 16-byte float vector properly when
                    converting upper part with -mavx2
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gabravier at gmail dot com
  Target Milestone: ---

typedef int v8si __attribute__((vector_size(32)));
typedef float v4sf __attribute__((vector_size(16)));

v4sf high (v8si *srcp)
{
  v8si src = *srcp;
  return (v4sf) { (float)src[4], (float)src[5], (float)src[6], (float)src[7] };
}

With -O3 -mavx2, GCC outputs this:

high(int __vector(8)*):
        vmovdqa ymm0, YMMWORD PTR [rdi]
        vperm2i128      ymm0, ymm0, ymm0, 17
        vcvtdq2ps       xmm0, xmm0
        vzeroupper
        ret

LLVM instead outputs this:

high(int __vector(8)*):
        vcvtdq2ps       xmm0, xmmword ptr [rdi + 16]
        ret

And GCC outputs the equivalent code if -mavx2 is removed:

high(int __vector(8)*):
        cvtdq2ps        xmm0, XMMWORD PTR [rdi+16]
        ret

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

* [Bug target/102583] [x86] Failure to optimize 32-byte integer vector conversion to 16-byte float vector properly when converting upper part with -mavx2
  2021-10-04  2:57 [Bug target/102583] New: [x86] Failure to optimize 32-byte integer vector conversion to 16-byte float vector properly when converting upper part with -mavx2 gabravier at gmail dot com
@ 2021-10-04  7:53 ` rguenth at gcc dot gnu.org
  2022-01-25  6:32 ` [Bug tree-optimization/102583] " crazylht at gmail dot com
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-10-04  7:53 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-10-04
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
We're lacking stripping of a load that's only used partially I guess. 
forwprop1
generates

  _1 = *srcp_11(D);
  _2 = BIT_FIELD_REF <_1, 32, 128>;
  _3 = (float) _2;
  _4 = BIT_FIELD_REF <_1, 32, 160>;
  _5 = (float) _4;
  _6 = BIT_FIELD_REF <_1, 32, 192>;
  _7 = (float) _6;
  _8 = BIT_FIELD_REF <_1, 32, 224>;
  _9 = (float) _8;
  _12 = VEC_PERM_EXPR <_1, _1, { 4, 5, 6, 7, 4, 5, 6, 7 }>;
  _15 = BIT_FIELD_REF <_12, 128, 0>;
  _16 = (vector(4) float) _15;

and the second forwprop then sees

  _1 = *srcp_3(D);
  _4 = VEC_PERM_EXPR <_1, _1, { 4, 5, 6, 7, 4, 5, 6, 7 }>;
  _5 = BIT_FIELD_REF <_4, 128, 0>;
  _6 = (vector(4) float) _5;

in a single-use chain we probably want to try swapping the
BIT_FIELD_REF and the VEC_PERM_EXPR so that we expose the
BIT_FIELD_REF directly to the load which we'd already handle.

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

* [Bug tree-optimization/102583] [x86] Failure to optimize 32-byte integer vector conversion to 16-byte float vector properly when converting upper part with -mavx2
  2021-10-04  2:57 [Bug target/102583] New: [x86] Failure to optimize 32-byte integer vector conversion to 16-byte float vector properly when converting upper part with -mavx2 gabravier at gmail dot com
  2021-10-04  7:53 ` [Bug target/102583] " rguenth at gcc dot gnu.org
@ 2022-01-25  6:32 ` crazylht at gmail dot com
  2022-01-25  9:06 ` crazylht at gmail dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: crazylht at gmail dot com @ 2022-01-25  6:32 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Hongtao.liu <crazylht at gmail dot com> ---
Simplify
  _4 = VEC_PERM_EXPR <_1, _1, { 4, 5, 6, 7, 4, 5, 6, 7 }>;
  _5 = BIT_FIELD_REF <_4, 128, 0>;

to

_5 = BIT_FIELD_REF <_1, 128, 128>;

in match.pd?

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

* [Bug tree-optimization/102583] [x86] Failure to optimize 32-byte integer vector conversion to 16-byte float vector properly when converting upper part with -mavx2
  2021-10-04  2:57 [Bug target/102583] New: [x86] Failure to optimize 32-byte integer vector conversion to 16-byte float vector properly when converting upper part with -mavx2 gabravier at gmail dot com
  2021-10-04  7:53 ` [Bug target/102583] " rguenth at gcc dot gnu.org
  2022-01-25  6:32 ` [Bug tree-optimization/102583] " crazylht at gmail dot com
@ 2022-01-25  9:06 ` crazylht at gmail dot com
  2022-04-08  7:28 ` crazylht at gmail dot com
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: crazylht at gmail dot com @ 2022-01-25  9:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Hongtao.liu <crazylht at gmail dot com> ---
(In reply to Hongtao.liu from comment #2)
> Simplify
>   _4 = VEC_PERM_EXPR <_1, _1, { 4, 5, 6, 7, 4, 5, 6, 7 }>;
>   _5 = BIT_FIELD_REF <_4, 128, 0>;
> 
> to
> 
> _5 = BIT_FIELD_REF <_1, 128, 128>;
> 
> in match.pd?

maybe forwprop this
15  _1 = *srcp_7(D);
16  _2 = BIT_FIELD_REF <_1, 32, 128>;
17  _3 = BIT_FIELD_REF <_1, 32, 160>;
18  _4 = BIT_FIELD_REF <_1, 32, 192>;
19  _5 = BIT_FIELD_REF <_1, 32, 224>;
20  b_9 = {_2, _3, _4, _5};

directly into

b_9 = BIT_FIELD_REF <*srcp_7, 128, 128>;

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

* [Bug tree-optimization/102583] [x86] Failure to optimize 32-byte integer vector conversion to 16-byte float vector properly when converting upper part with -mavx2
  2021-10-04  2:57 [Bug target/102583] New: [x86] Failure to optimize 32-byte integer vector conversion to 16-byte float vector properly when converting upper part with -mavx2 gabravier at gmail dot com
                   ` (2 preceding siblings ...)
  2022-01-25  9:06 ` crazylht at gmail dot com
@ 2022-04-08  7:28 ` crazylht at gmail dot com
  2022-05-13  1:04 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: crazylht at gmail dot com @ 2022-04-08  7:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Hongtao.liu <crazylht at gmail dot com> ---
Created attachment 52771
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52771&action=edit
Pending patch for GCC13.

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

* [Bug tree-optimization/102583] [x86] Failure to optimize 32-byte integer vector conversion to 16-byte float vector properly when converting upper part with -mavx2
  2021-10-04  2:57 [Bug target/102583] New: [x86] Failure to optimize 32-byte integer vector conversion to 16-byte float vector properly when converting upper part with -mavx2 gabravier at gmail dot com
                   ` (3 preceding siblings ...)
  2022-04-08  7:28 ` crazylht at gmail dot com
@ 2022-05-13  1:04 ` cvs-commit at gcc dot gnu.org
  2022-05-13  1:19 ` crazylht at gmail dot com
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-13  1:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by hongtao Liu <liuhongt@gcc.gnu.org>:

https://gcc.gnu.org/g:8ab4b484153031c407b7d8c760b6a2605da1199a

commit r13-379-g8ab4b484153031c407b7d8c760b6a2605da1199a
Author: liuhongt <hongtao.liu@intel.com>
Date:   Fri Apr 8 11:26:46 2022 +0800

    Strip of a vector load which is only used partially.

    Optimize

      _4 = VEC_PERM_EXPR <_1, _1, { 4, 5, 6, 7, 4, 5, 6, 7 }>;
      _5 = BIT_FIELD_REF <_4, 128, 0>;

    to

      _5 = BIT_FIELD_REF <_1, 128, 128>;

    gcc/ChangeLog:

            PR tree-optimization/102583
            * tree-ssa-forwprop.cc (simplify_bitfield_ref): Extended to a
            contiguous stride in the VEC_PERM_EXPR.

    gcc/testsuite/ChangeLog:

            * gcc.target/i386/pr102583.c: New test.
            * gcc.target/i386/pr92645-2.c: Adjust testcase.
            * gcc.target/i386/pr92645-3.c: Ditto.

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

* [Bug tree-optimization/102583] [x86] Failure to optimize 32-byte integer vector conversion to 16-byte float vector properly when converting upper part with -mavx2
  2021-10-04  2:57 [Bug target/102583] New: [x86] Failure to optimize 32-byte integer vector conversion to 16-byte float vector properly when converting upper part with -mavx2 gabravier at gmail dot com
                   ` (4 preceding siblings ...)
  2022-05-13  1:04 ` cvs-commit at gcc dot gnu.org
@ 2022-05-13  1:19 ` crazylht at gmail dot com
  2022-05-16 22:11 ` gabravier at gmail dot com
  2022-05-16 23:09 ` hjl.tools at gmail dot com
  7 siblings, 0 replies; 9+ messages in thread
From: crazylht at gmail dot com @ 2022-05-13  1:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Hongtao.liu <crazylht at gmail dot com> ---
Fixed in GCC13.

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

* [Bug tree-optimization/102583] [x86] Failure to optimize 32-byte integer vector conversion to 16-byte float vector properly when converting upper part with -mavx2
  2021-10-04  2:57 [Bug target/102583] New: [x86] Failure to optimize 32-byte integer vector conversion to 16-byte float vector properly when converting upper part with -mavx2 gabravier at gmail dot com
                   ` (5 preceding siblings ...)
  2022-05-13  1:19 ` crazylht at gmail dot com
@ 2022-05-16 22:11 ` gabravier at gmail dot com
  2022-05-16 23:09 ` hjl.tools at gmail dot com
  7 siblings, 0 replies; 9+ messages in thread
From: gabravier at gmail dot com @ 2022-05-16 22:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Gabriel Ravier <gabravier at gmail dot com> ---
Can confirm it is indeed fixed

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

* [Bug tree-optimization/102583] [x86] Failure to optimize 32-byte integer vector conversion to 16-byte float vector properly when converting upper part with -mavx2
  2021-10-04  2:57 [Bug target/102583] New: [x86] Failure to optimize 32-byte integer vector conversion to 16-byte float vector properly when converting upper part with -mavx2 gabravier at gmail dot com
                   ` (6 preceding siblings ...)
  2022-05-16 22:11 ` gabravier at gmail dot com
@ 2022-05-16 23:09 ` hjl.tools at gmail dot com
  7 siblings, 0 replies; 9+ messages in thread
From: hjl.tools at gmail dot com @ 2022-05-16 23:09 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |13.0
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #8 from H.J. Lu <hjl.tools at gmail dot com> ---
Fixed for GCC 13.

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

end of thread, other threads:[~2022-05-16 23:09 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-04  2:57 [Bug target/102583] New: [x86] Failure to optimize 32-byte integer vector conversion to 16-byte float vector properly when converting upper part with -mavx2 gabravier at gmail dot com
2021-10-04  7:53 ` [Bug target/102583] " rguenth at gcc dot gnu.org
2022-01-25  6:32 ` [Bug tree-optimization/102583] " crazylht at gmail dot com
2022-01-25  9:06 ` crazylht at gmail dot com
2022-04-08  7:28 ` crazylht at gmail dot com
2022-05-13  1:04 ` cvs-commit at gcc dot gnu.org
2022-05-13  1:19 ` crazylht at gmail dot com
2022-05-16 22:11 ` gabravier at gmail dot com
2022-05-16 23:09 ` hjl.tools at gmail dot com

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