This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Hi,
With altivec we can have two vec_splat in a row but there is nothing
currently in GCC that is able to optimize the code to be only
vec_splat.
Currently the two vec_splat's RTL look like:
(insn 6 3 7 2 gcc/gcc/testsuite/gcc.target/powerpc/altivec-33.c:12
(set (reg:V4SI 120 [ D.2899 ])
(vec_duplicate:V4SI (vec_select:SI (subreg:V4SI (reg/v:V4SF
126 [ a ]) 0)
(parallel [
(const_int 2 [0x2])
])))) 1102 {altivec_vspltw} (expr_list:REG_DEAD
(reg/v:V4SF 126 [ a ])
(nil)))
(insn 7 6 8 2 gcc/gcc/testsuite/gcc.target/powerpc/altivec-33.c:13
(set (reg:V4SF 127 [ D.2899 ])
(subreg:V4SF (reg:V4SI 120 [ D.2899 ]) 0)) 925
{*altivec_movv4sf} (expr_list:REG_DEAD (reg:V4SI 120 [ D.2899 ])
(nil)))
(insn 8 7 13 2 gcc/gcc/testsuite/gcc.target/powerpc/altivec-33.c:13
(set (reg:V4SI 123 [ D.2903 ])
(vec_duplicate:V4SI (vec_select:SI (subreg:V4SI (reg:V4SF 127
[ D.2899 ]) 0)
(parallel [
(const_int 0 [0x0])
])))) 1102 {altivec_vspltw} (expr_list:REG_DEAD
(reg:V4SF 127 [ D.2899 ])
(nil)))
So when combine these three instructions, we don't optimize the
(vec_select:SI (vec_duplicate:V4SI (XYZ:SI) )) into (XYZ:SI) It does
not matter what (XYZ:SI) or what element the vec_select is selecting
as every element will be the same (XYZ:SI).
This patch adds to simplify-rtx.c (simplify_binary_operation_1), this
optimization and adds a testcase for the Altivec case.
Note this patch has been in the PS3 toolchain for a long time now.
OK? Bootstrapped and tested on powerpc64-linux-gnu with no regressions.
Thanks,
Andrew Pinski
ChangeLog:
* simplify-rtx.c (simplify_binary_operation_1): Simplify vec_select of
a vec_duplicate.
* gcc.target/powerpc/altivec-33.c: New testcase.
Attachment:
fixvecselectdup.diff.txt
Description: Text document
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |