public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/26546] New: Passing unions of _vector_ types and struct or array of the same size as value to inline functions causes unecessary load/stores on the stack even if no members except the _vector_ is accessed
@ 2006-03-03 11:44 j_daniel at rbg dot informatik dot tu-darmstadt dot de
2006-03-03 13:48 ` [Bug tree-optimization/26546] " pinskia at gcc dot gnu dot org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: j_daniel at rbg dot informatik dot tu-darmstadt dot de @ 2006-03-03 11:44 UTC (permalink / raw)
To: gcc-bugs
Consider this example:
#include <xmmintrin.h>
typedef union
{
__m128 vec;
float data[4];
struct
{
float x,y,z,w;
};
} vec4f_t;
static inline float __attribute__((__always_inline__))
acc(vec4f_t src)
{
float a;
src.vec = _mm_add_ps(src.vec, _mm_movehl_ps(src.vec, src.vec,));
_mm_store_ss(&a, _mm_add_ss(src.vec, _mm_shuffle_ps(src.vec, src.vec,
_MM_SHUFFLE(3,2,1,1))));
return a;
}
int
main(int argc, char *argv[])
{
vec4f_t b;
printf("%f\n", acc(b));
return 0;
}
This gets compiled to:
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
.string "%f\n"
.text
.p2align 4,,15
.globl main
.type main, @function
main:
.LFB506:
subq $40, %rsp
.LCFI0:
movl $.LC0, %edi
movq 16(%rsp), %rax
movq %rax, (%rsp)
movq 24(%rsp), %rax
movq %rax, 8(%rsp)
movl $1, %eax
movaps (%rsp), %xmm1
movaps %xmm1, %xmm0
movhlps %xmm1, %xmm0
addps %xmm1, %xmm0
movaps %xmm0, %xmm1
shufps $229, %xmm0, %xmm1
addss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
call printf
xorl %eax, %eax
addq $40, %rsp
ret
As we can see the union is passed on the stack instead of a value in %xmm0 this
would make sense if this would not be an inline function and members other than
the __m128 would be accessed.
Using the same code as above but passing __m128 directly instead of the union
gets compiled to:
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
.string "%f\n"
.text
.p2align 4,,15
.globl main
.type main, @function
main:
.LFB506:
movhlps %xmm0, %xmm0
subq $8, %rsp
.LCFI0:
movl $.LC0, %edi
movl $1, %eax
addps %xmm0, %xmm0
movaps %xmm0, %xmm1
shufps $229, %xmm0, %xmm1
addss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
call printf
xorl %eax, %eax
addq $8, %rsp
ret
--
Summary: Passing unions of _vector_ types and struct or array of
the same size as value to inline functions causes
unecessary load/stores on the stack even if no members
except the _vector_ is accessed
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: other
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: j_daniel at rbg dot informatik dot tu-darmstadt dot de
GCC build triplet: x86_64-pc-linux-gnu
GCC host triplet: x86_64-pc-linux-gnu
GCC target triplet: x86_64-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26546
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/26546] Passing unions of _vector_ types and struct or array of the same size as value to inline functions causes unecessary load/stores on the stack even if no members except the _vector_ is accessed
2006-03-03 11:44 [Bug other/26546] New: Passing unions of _vector_ types and struct or array of the same size as value to inline functions causes unecessary load/stores on the stack even if no members except the _vector_ is accessed j_daniel at rbg dot informatik dot tu-darmstadt dot de
@ 2006-03-03 13:48 ` pinskia at gcc dot gnu dot org
2006-03-03 13:56 ` pinskia at gcc dot gnu dot org
2006-03-03 14:02 ` [Bug tree-optimization/26546] [meta-bugs] couple of missed optimization with respect of vector and unions pinskia at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-03-03 13:48 UTC (permalink / raw)
To: gcc-bugs
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pinskia at gcc dot gnu dot
| |org
Severity|normal |enhancement
Component|other |tree-optimization
Keywords| |missed-optimization
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26546
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/26546] Passing unions of _vector_ types and struct or array of the same size as value to inline functions causes unecessary load/stores on the stack even if no members except the _vector_ is accessed
2006-03-03 11:44 [Bug other/26546] New: Passing unions of _vector_ types and struct or array of the same size as value to inline functions causes unecessary load/stores on the stack even if no members except the _vector_ is accessed j_daniel at rbg dot informatik dot tu-darmstadt dot de
2006-03-03 13:48 ` [Bug tree-optimization/26546] " pinskia at gcc dot gnu dot org
@ 2006-03-03 13:56 ` pinskia at gcc dot gnu dot org
2006-03-03 14:02 ` [Bug tree-optimization/26546] [meta-bugs] couple of missed optimization with respect of vector and unions pinskia at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-03-03 13:56 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2006-03-03 13:56 -------
I think this is just because b is used un-initialized.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26546
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/26546] [meta-bugs] couple of missed optimization with respect of vector and unions
2006-03-03 11:44 [Bug other/26546] New: Passing unions of _vector_ types and struct or array of the same size as value to inline functions causes unecessary load/stores on the stack even if no members except the _vector_ is accessed j_daniel at rbg dot informatik dot tu-darmstadt dot de
2006-03-03 13:48 ` [Bug tree-optimization/26546] " pinskia at gcc dot gnu dot org
2006-03-03 13:56 ` pinskia at gcc dot gnu dot org
@ 2006-03-03 14:02 ` pinskia at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-03-03 14:02 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pinskia at gcc dot gnu dot org 2006-03-03 14:02 -------
Actually nope. There are a couple of different issues here.
First is store_copyprop does not work:
# SFT.10_29 = V_MAY_DEF <SFT.10_10>;
# SFT.11_30 = V_MAY_DEF <SFT.11_11>;
# SFT.12_31 = V_MAY_DEF <SFT.12_12>;
# SFT.14_32 = V_MAY_DEF <SFT.14_14>;
# SFT.13_28 = V_MUST_DEF <SFT.13_13>;
src.vec = D.5885_25;
# VUSE <SFT.10_29>;
# VUSE <SFT.11_30>;
# VUSE <SFT.12_31>;
# VUSE <SFT.13_28>;
# VUSE <SFT.14_32>;
D.5880_33 = src.vec;
Which is PR 26135.
The second issue is no copyprop for aggregates:
# SFT.10_10 = V_MUST_DEF <SFT.10_5>;
# SFT.11_11 = V_MUST_DEF <SFT.11_6>;
# SFT.12_12 = V_MUST_DEF <SFT.12_7>;
# SFT.13_13 = V_MUST_DEF <SFT.13_8>;
# SFT.14_14 = V_MUST_DEF <SFT.14_9>;
# VUSE <b_4>;
src = b;
# VUSE <SFT.10_10>;
# VUSE <SFT.11_11>;
# VUSE <SFT.12_12>;
# VUSE <SFT.13_13>;
# VUSE <SFT.14_14>;
D.5880_15 = src.vec;
Which is PR 14295.
After those two are fixed, this should be fixed Also.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
BugsThisDependsOn| |14295, 26135
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
GCC build triplet|x86_64-pc-linux-gnu |
GCC host triplet|x86_64-pc-linux-gnu |
GCC target triplet|x86_64-pc-linux-gnu |
Last reconfirmed|0000-00-00 00:00:00 |2006-03-03 14:02:47
date| |
Summary|Passing unions of _vector_ |[meta-bugs] couple of missed
|types and struct or array of|optimization with respect of
|the same size as value to |vector and unions
|inline functions causes |
|unecessary load/stores on |
|the stack even if no members|
|except the _vector_ is |
|accessed |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26546
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-03-03 14:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-03 11:44 [Bug other/26546] New: Passing unions of _vector_ types and struct or array of the same size as value to inline functions causes unecessary load/stores on the stack even if no members except the _vector_ is accessed j_daniel at rbg dot informatik dot tu-darmstadt dot de
2006-03-03 13:48 ` [Bug tree-optimization/26546] " pinskia at gcc dot gnu dot org
2006-03-03 13:56 ` pinskia at gcc dot gnu dot org
2006-03-03 14:02 ` [Bug tree-optimization/26546] [meta-bugs] couple of missed optimization with respect of vector and unions pinskia at gcc dot gnu dot 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).