diff options
author | glisse <glisse@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-10-01 09:53:26 +0000 |
---|---|---|
committer | glisse <glisse@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-10-01 09:53:26 +0000 |
commit | 3cc18861212f992470d0e8edce992792ca23872b (patch) | |
tree | 323d8a354041efc900f2e813aecb6d428aa1da25 /gcc | |
parent | 71e95bca7df79ed6cf65e5642071db409f1a8fc7 (diff) | |
download | gcc-3cc18861212f992470d0e8edce992792ca23872b.tar.gz |
2012-10-01 Marc Glisse <marc.glisse@inria.fr>
gcc/
* simplify-rtx.c (simplify_binary_operation_1) <VEC_SELECT>:
Detect the identity.
<VEC_CONCAT>: Handle VEC_SELECTs from the same vector.
gcc/testsuite/
* gcc.target/i386/vect-rebuild.c: New testcase.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@191909 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/simplify-rtx.c | 35 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/vect-rebuild.c | 33 |
4 files changed, 78 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2acf70a3077..35c062c5979 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2012-10-01 Marc Glisse <marc.glisse@inria.fr> + + * simplify-rtx.c (simplify_binary_operation_1) <VEC_SELECT>: + Detect the identity. + <VEC_CONCAT>: Handle VEC_SELECTs from the same vector. + 2012-10-01 Oleg Endo <olegendo@gcc.gnu.org> PR target/50457 diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index af85ccc0836..aebe6bbd93b 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -3246,6 +3246,23 @@ simplify_binary_operation_1 (enum rtx_code code, enum machine_mode mode, return gen_rtx_CONST_VECTOR (mode, v); } + /* Recognize the identity. */ + if (GET_MODE (trueop0) == mode) + { + bool maybe_ident = true; + for (int i = 0; i < XVECLEN (trueop1, 0); i++) + { + rtx j = XVECEXP (trueop1, 0, i); + if (!CONST_INT_P (j) || INTVAL (j) != i) + { + maybe_ident = false; + break; + } + } + if (maybe_ident) + return trueop0; + } + /* If we build {a,b} then permute it, build the result directly. */ if (XVECLEN (trueop1, 0) == 2 && CONST_INT_P (XVECEXP (trueop1, 0, 0)) @@ -3371,6 +3388,24 @@ simplify_binary_operation_1 (enum rtx_code code, enum machine_mode mode, return gen_rtx_CONST_VECTOR (mode, v); } + + /* Try to merge VEC_SELECTs from the same vector into a single one. */ + if (GET_CODE (trueop0) == VEC_SELECT + && GET_CODE (trueop1) == VEC_SELECT + && rtx_equal_p (XEXP (trueop0, 0), XEXP (trueop1, 0))) + { + rtx par0 = XEXP (trueop0, 1); + rtx par1 = XEXP (trueop1, 1); + int len0 = XVECLEN (par0, 0); + int len1 = XVECLEN (par1, 0); + rtvec vec = rtvec_alloc (len0 + len1); + for (int i = 0; i < len0; i++) + RTVEC_ELT (vec, i) = XVECEXP (par0, 0, i); + for (int i = 0; i < len1; i++) + RTVEC_ELT (vec, len0 + i) = XVECEXP (par1, 0, i); + return simplify_gen_binary (VEC_SELECT, mode, XEXP (trueop0, 0), + gen_rtx_PARALLEL (VOIDmode, vec)); + } } return 0; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8b0c58df86f..aa9ddad7a84 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2012-10-01 Marc Glisse <marc.glisse@inria.fr> + + * gcc.target/i386/vect-rebuild.c: New testcase. + 2012-09-30 Uros Bizjak <ubizjak@gmail.com> * gcc.target/i386/pad-10.c (foo2): Return x - z. diff --git a/gcc/testsuite/gcc.target/i386/vect-rebuild.c b/gcc/testsuite/gcc.target/i386/vect-rebuild.c new file mode 100644 index 00000000000..570967f6b5c --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/vect-rebuild.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-O -mavx -fno-tree-forwprop" } */ + +typedef double v2df __attribute__ ((__vector_size__ (16))); +typedef double v4df __attribute__ ((__vector_size__ (32))); + +v2df f1 (v2df x) +{ + v2df xx = { x[0], x[1] }; + return xx; +} + +v4df f2 (v4df x) +{ + v4df xx = { x[0], x[1], x[2], x[3] }; + return xx; +} + +v2df g (v2df x) +{ + v2df xx = { x[1], x[0] }; + return xx; +} + +v2df h (v4df x) +{ + v2df xx = { x[2], x[3] }; + return xx; +} + +/* { dg-final { scan-assembler-not "unpck" } } */ +/* { dg-final { scan-assembler-times "\tv?permilpd\[ \t\]" 1 } } */ +/* { dg-final { scan-assembler-times "\tv?extractf128\[ \t\]" 1 } } */ |