diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0c100df55aa9..3f74243c00b9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2012-08-17 Marc Glisse + + * simplify-rtx.c (simplify_binary_operation_1): Optimize shuffle of + a concatenation. + + 2012-08-17 H.J. Lu * stor-layout.c (compute_record_mode): Replace diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 16dbd8a03eaf..a878048ac979 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -3253,6 +3253,23 @@ simplify_binary_operation_1 (enum rtx_code code, enum machine_mode mode, subop0 = XEXP (XEXP (trueop0, i0 / 2), i0 % 2); subop1 = XEXP (XEXP (trueop0, i1 / 2), i1 % 2); + return simplify_gen_binary (VEC_CONCAT, mode, subop0, subop1); + } + + if (XVECLEN (trueop1, 0) == 2 + && CONST_INT_P (XVECEXP (trueop1, 0, 0)) + && CONST_INT_P (XVECEXP (trueop1, 0, 1)) + && GET_CODE (trueop0) == VEC_CONCAT + && GET_MODE (trueop0) == mode) + { + unsigned int i0 = INTVAL (XVECEXP (trueop1, 0, 0)); + unsigned int i1 = INTVAL (XVECEXP (trueop1, 0, 1)); + rtx subop0, subop1; + + gcc_assert (i0 < 2 && i1 < 2); + subop0 = XEXP (trueop0, i0); + subop1 = XEXP (trueop0, i1); + return simplify_gen_binary (VEC_CONCAT, mode, subop0, subop1); } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3936642d60f6..6f561b860395 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2012-08-17 Marc Glisse + + * gcc.target/i386/perm-concat.c: New test. + 2012-08-17 Julian Brown * gcc.target/arm/div64-unwinding.c: New test. diff --git a/gcc/testsuite/gcc.target/i386/perm-concat.c b/gcc/testsuite/gcc.target/i386/perm-concat.c new file mode 100644 index 000000000000..10955c2073e4 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/perm-concat.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O -mavx -mfpmath=sse" } */ + +typedef double v2df __attribute__ ((__vector_size__ (16))); + +v2df +f (double d) +{ + v2df x = {-d, d}; + return __builtin_ia32_vpermilpd (x, 1); +} + +/* { dg-final { scan-assembler-not "\tvpermilpd\[ \t\]" } } */