public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/48609] New: Inefficient complex float store
@ 2011-04-14 13:57 hjl.tools at gmail dot com
  2011-04-14 14:04 ` [Bug target/48609] Inefficient complex float load/store hjl.tools at gmail dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: hjl.tools at gmail dot com @ 2011-04-14 13:57 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48609

           Summary: Inefficient complex float store
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: hjl.tools@gmail.com
                CC: ubizjak@gmail.com
            Target: x86_64


[hjl@gnu-6 pr1000]$ cat s2.i
typedef _Complex float SCtype;
extern SCtype bar;
void
foo (SCtype x)
{
  bar = x;
}
[hjl@gnu-6 pr1000]$ /usr/gcc-4.7/bin/gcc -S -O2 s2.i   
[hjl@gnu-6 pr1000]$ cat s2.s
    .file    "s2.i"
    .text
    .p2align 4,,15
    .globl    foo
    .type    foo, @function
foo:
.LFB0:
    .cfi_startproc
    movq    %xmm0, -8(%rsp)
    movl    -8(%rsp), %eax
    movl    %eax, bar(%rip)
    movl    -4(%rsp), %eax
    movl    %eax, bar+4(%rip)
    ret
    .cfi_endproc
.LFE0:
    .size    foo, .-foo

We should simply do

movq    %xmm0, bar(%rip)


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

* [Bug target/48609] Inefficient complex float load/store
  2011-04-14 13:57 [Bug target/48609] New: Inefficient complex float store hjl.tools at gmail dot com
@ 2011-04-14 14:04 ` hjl.tools at gmail dot com
  2021-08-02 18:02 ` [Bug middle-end/48609] Inefficient complex float argument passing/return pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: hjl.tools at gmail dot com @ 2011-04-14 14:04 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48609

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Inefficient complex float   |Inefficient complex float
                   |store                       |load/store

--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> 2011-04-14 14:04:20 UTC ---
Load has the same problem:

[hjl@gnu-6 pr1000]$ cat load.i
typedef _Complex float SCtype;
extern SCtype foo;
SCtype
bar ()
{
  return foo;
}
[hjl@gnu-6 pr1000]$ /usr/gcc-4.7/bin/gcc -S -O2  load.i   
[hjl@gnu-6 pr1000]$ cat load.s
    .file    "load.i"
    .text
    .p2align 4,,15
    .globl    bar
    .type    bar, @function
bar:
.LFB0:
    .cfi_startproc
    movl    foo(%rip), %eax
    movl    %eax, -8(%rsp)
    movl    foo+4(%rip), %eax
    movl    %eax, -4(%rsp)
    movq    -8(%rsp), %xmm0
    ret
    .cfi_endproc
.LFE0:
    .size    bar, .-bar


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

* [Bug middle-end/48609] Inefficient complex float argument passing/return
  2011-04-14 13:57 [Bug target/48609] New: Inefficient complex float store hjl.tools at gmail dot com
  2011-04-14 14:04 ` [Bug target/48609] Inefficient complex float load/store hjl.tools at gmail dot com
@ 2021-08-02 18:02 ` pinskia at gcc dot gnu.org
  2021-08-02 18:06 ` pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-02 18:02 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-08-02
           Keywords|                            |missed-optimization
             Status|UNCONFIRMED                 |NEW
            Summary|Inefficient complex float   |Inefficient complex float
                   |load/store                  |argument passing/return
     Ever confirmed|0                           |1
          Component|target                      |middle-end

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed, In this case, it is a middle-end issue, I suspect if we used
V2SFmode for the incoming argument, it might work better.  Right now we
produce:
(insn 2 9 3 2 (set (reg:DI 86)
        (reg:DI 20 xmm0 [ x ])) "/app/example.cpp":5:1 -1
     (nil))
(insn 3 2 4 2 (set (mem/c:DI (plus:DI (reg/f:DI 77 virtual-stack-vars)
                (const_int -8 [0xfffffffffffffff8])) [0  S8 A64])
        (reg:DI 86)) "/app/example.cpp":5:1 -1
     (nil))
(insn 4 3 5 2 (set (reg:SF 84)
        (mem/c:SF (plus:DI (reg/f:DI 77 virtual-stack-vars)
                (const_int -8 [0xfffffffffffffff8])) [0  S4 A64]))
"/app/example.cpp":5:1 -1
     (nil))
(insn 5 4 6 2 (set (reg:SF 85)
        (mem/c:SF (plus:DI (reg/f:DI 77 virtual-stack-vars)
                (const_int -4 [0xfffffffffffffffc])) [0  S4 A32]))
"/app/example.cpp":5:1 -1
     (nil))

----- CUT ----
Return has the same issue:
(insn 13 12 14 2 (set (mem/c:SF (plus:DI (reg/f:DI 77 virtual-stack-vars)
                (const_int -8 [0xfffffffffffffff8])) [0  S4 A32])
        (reg:SF 84)) "/app/example.cpp":7:1 -1
     (nil))
(insn 14 13 15 2 (set (mem/c:SF (plus:DI (reg/f:DI 77 virtual-stack-vars)
                (const_int -4 [0xfffffffffffffffc])) [0  S4 A32])
        (reg:SF 85)) "/app/example.cpp":7:1 -1
     (nil))
(insn 15 14 16 2 (set (reg:DI 20 xmm0)
        (mem/c:DI (plus:DI (reg/f:DI 77 virtual-stack-vars)
                (const_int -8 [0xfffffffffffffff8])) [0  S8 A32]))
"/app/example.cpp":7:1 -1
     (nil))

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

* [Bug middle-end/48609] Inefficient complex float argument passing/return
  2011-04-14 13:57 [Bug target/48609] New: Inefficient complex float store hjl.tools at gmail dot com
  2011-04-14 14:04 ` [Bug target/48609] Inefficient complex float load/store hjl.tools at gmail dot com
  2021-08-02 18:02 ` [Bug middle-end/48609] Inefficient complex float argument passing/return pinskia at gcc dot gnu.org
@ 2021-08-02 18:06 ` pinskia at gcc dot gnu.org
  2021-08-07  5:28 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-02 18:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 48607 has been marked as a duplicate of this bug. ***

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

* [Bug middle-end/48609] Inefficient complex float argument passing/return
  2011-04-14 13:57 [Bug target/48609] New: Inefficient complex float store hjl.tools at gmail dot com
                   ` (2 preceding siblings ...)
  2021-08-02 18:06 ` pinskia at gcc dot gnu.org
@ 2021-08-07  5:28 ` pinskia at gcc dot gnu.org
  2021-08-17 10:35 ` crazylht at gmail dot com
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-07  5:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 77851 has been marked as a duplicate of this bug. ***

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

* [Bug middle-end/48609] Inefficient complex float argument passing/return
  2011-04-14 13:57 [Bug target/48609] New: Inefficient complex float store hjl.tools at gmail dot com
                   ` (3 preceding siblings ...)
  2021-08-07  5:28 ` pinskia at gcc dot gnu.org
@ 2021-08-17 10:35 ` crazylht at gmail dot com
  2021-08-17 10:44 ` crazylht at gmail dot com
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: crazylht at gmail dot com @ 2021-08-17 10:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Hongtao.liu <crazylht at gmail dot com> ---
(In reply to Andrew Pinski from comment #2)
> Confirmed, In this case, it is a middle-end issue, I suspect if we used
> V2SFmode for the incoming argument, it might work better.  Right now we
Yes, under TAREGT_SSE2 and TARGET_64BIT, we support movv2sf, i think it's
reasonable to use V2SFmode instead of DImode as incoming argument mode for
SCmode.

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

* [Bug middle-end/48609] Inefficient complex float argument passing/return
  2011-04-14 13:57 [Bug target/48609] New: Inefficient complex float store hjl.tools at gmail dot com
                   ` (4 preceding siblings ...)
  2021-08-17 10:35 ` crazylht at gmail dot com
@ 2021-08-17 10:44 ` crazylht at gmail dot com
  2021-08-17 10:55 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: crazylht at gmail dot com @ 2021-08-17 10:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Hongtao.liu <crazylht at gmail dot com> ---
(In reply to Hongtao.liu from comment #5)
> (In reply to Andrew Pinski from comment #2)
> > Confirmed, In this case, it is a middle-end issue, I suspect if we used
> > V2SFmode for the incoming argument, it might work better.  Right now we
> Yes, under TAREGT_SSE2 and TARGET_64BIT, we support movv2sf, i think it's
> reasonable to use V2SFmode instead of DImode as incoming argument mode for
> SCmode.

Doesn't help here

foo:
.LFB0:
        .cfi_startproc
        movlps  %xmm0, -8(%rsp) # 3     [c=4 l=5]  *movv2sf_internal/14
        movss   -8(%rsp), %xmm0 # 16    [c=8 l=6]  *movsf_internal/7
        movss   %xmm0, bar(%rip)        # 11    [c=4 l=8]  *movsf_internal/8
        movss   -4(%rsp), %xmm0 # 17    [c=8 l=6]  *movsf_internal/7
        movss   %xmm0, bar+4(%rip)      # 12    [c=4 l=8]  *movsf_internal/8
        ret             # 21    [c=0 l=1]  simple_return_internal

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

* [Bug middle-end/48609] Inefficient complex float argument passing/return
  2011-04-14 13:57 [Bug target/48609] New: Inefficient complex float store hjl.tools at gmail dot com
                   ` (5 preceding siblings ...)
  2021-08-17 10:44 ` crazylht at gmail dot com
@ 2021-08-17 10:55 ` pinskia at gcc dot gnu.org
  2021-08-17 11:42 ` crazylht at gmail dot com
  2021-08-17 12:25 ` crazylht at gmail dot com
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-17 10:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Hongtao.liu from comment #6)
> (In reply to Hongtao.liu from comment #5)
> > (In reply to Andrew Pinski from comment #2)
> > > Confirmed, In this case, it is a middle-end issue, I suspect if we used
> > > V2SFmode for the incoming argument, it might work better.  Right now we
> > Yes, under TAREGT_SSE2 and TARGET_64BIT, we support movv2sf, i think it's
> > reasonable to use V2SFmode instead of DImode as incoming argument mode for
> > SCmode.
> 
> Doesn't help here
> 
> foo:
> .LFB0:
> 	.cfi_startproc
> 	movlps	%xmm0, -8(%rsp)	# 3	[c=4 l=5]  *movv2sf_internal/14
> 	movss	-8(%rsp), %xmm0	# 16	[c=8 l=6]  *movsf_internal/7
> 	movss	%xmm0, bar(%rip)	# 11	[c=4 l=8]  *movsf_internal/8
> 	movss	-4(%rsp), %xmm0	# 17	[c=8 l=6]  *movsf_internal/7
> 	movss	%xmm0, bar+4(%rip)	# 12	[c=4 l=8]  *movsf_internal/8
> 	ret		# 21	[c=0 l=1]  simple_return_internal

You have to do a little bit more. Like change how the extraction for the two
parts for the concat.

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

* [Bug middle-end/48609] Inefficient complex float argument passing/return
  2011-04-14 13:57 [Bug target/48609] New: Inefficient complex float store hjl.tools at gmail dot com
                   ` (6 preceding siblings ...)
  2021-08-17 10:55 ` pinskia at gcc dot gnu.org
@ 2021-08-17 11:42 ` crazylht at gmail dot com
  2021-08-17 12:25 ` crazylht at gmail dot com
  8 siblings, 0 replies; 10+ messages in thread
From: crazylht at gmail dot com @ 2021-08-17 11:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Hongtao.liu <crazylht at gmail dot com> ---
> You have to do a little bit more. Like change how the extraction for the two
> parts for the concat.

We already have vec_extractv2sfsf/vec_setv2sf, will debug to figure out why
they're not used.

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

* [Bug middle-end/48609] Inefficient complex float argument passing/return
  2011-04-14 13:57 [Bug target/48609] New: Inefficient complex float store hjl.tools at gmail dot com
                   ` (7 preceding siblings ...)
  2021-08-17 11:42 ` crazylht at gmail dot com
@ 2021-08-17 12:25 ` crazylht at gmail dot com
  8 siblings, 0 replies; 10+ messages in thread
From: crazylht at gmail dot com @ 2021-08-17 12:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Hongtao.liu <crazylht at gmail dot com> ---
(In reply to Hongtao.liu from comment #8)
> > You have to do a little bit more. Like change how the extraction for the two
> > parts for the concat.
> 
> We already have vec_extractv2sfsf/vec_setv2sf, will debug to figure out why
> they're not used.

we are using stack to copy from V2SF to concat:SC
src: (reg:V2SF 20 xmm0 [ x ])
dest: (concat:SC (reg:SF 84)
        (reg:SF 85))

----cut from emit_group_store-----------------
              else
                {
                  dest = assign_stack_temp (tmp_mode,
                                            GET_MODE_SIZE (tmp_mode));
                  emit_move_insn (dest, tmps[i]);
                  dst = adjust_address (dest, dest_mode, bytepos);
                }
              break;
-------cut end---------------------

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

end of thread, other threads:[~2021-08-17 12:25 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-14 13:57 [Bug target/48609] New: Inefficient complex float store hjl.tools at gmail dot com
2011-04-14 14:04 ` [Bug target/48609] Inefficient complex float load/store hjl.tools at gmail dot com
2021-08-02 18:02 ` [Bug middle-end/48609] Inefficient complex float argument passing/return pinskia at gcc dot gnu.org
2021-08-02 18:06 ` pinskia at gcc dot gnu.org
2021-08-07  5:28 ` pinskia at gcc dot gnu.org
2021-08-17 10:35 ` crazylht at gmail dot com
2021-08-17 10:44 ` crazylht at gmail dot com
2021-08-17 10:55 ` pinskia at gcc dot gnu.org
2021-08-17 11:42 ` crazylht at gmail dot com
2021-08-17 12:25 ` crazylht 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).