From: Jakub Jelinek Date: Thu, 27 Sep 2012 10:48:07 +0000 (+0200) Subject: re PR target/54703 (_mm_sub_pd is incorrectly substituted with vandnps) X-Git-Tag: misc/gccgo-go1_1_2~606 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6b74529d9b26ae4d4fd0bdb96b9ce44c40738c9f;p=thirdparty%2Fgcc.git re PR target/54703 (_mm_sub_pd is incorrectly substituted with vandnps) PR target/54703 * simplify-rtx.c (simplify_binary_operation_1): Perform (x - (x & y)) -> (x & ~y) optimization only for integral modes. * gcc.target/i386/pr54703.c: New test. From-SVN: r191801 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5850528c51e9..747039adfcef 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2012-09-27 Jakub Jelinek + + PR target/54703 + * simplify-rtx.c (simplify_binary_operation_1): Perform + (x - (x & y)) -> (x & ~y) optimization only for integral + modes. + 2012-09-27 Marc Glisse PR c/53024 diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 6b4b9f05d655..af85ccc08368 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -2239,7 +2239,7 @@ simplify_binary_operation_1 (enum rtx_code code, enum machine_mode mode, neg_const_int (mode, op1)); /* (x - (x & y)) -> (x & ~y) */ - if (GET_CODE (op1) == AND) + if (INTEGRAL_MODE_P (mode) && GET_CODE (op1) == AND) { if (rtx_equal_p (op0, XEXP (op1, 0))) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ac9e619db75c..c23166ee24a8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-09-27 Jakub Jelinek + + PR target/54703 + * gcc.target/i386/pr54703.c: New test. + 2012-09-27 Richard Guenther PR lto/54709 diff --git a/gcc/testsuite/gcc.target/i386/pr54703.c b/gcc/testsuite/gcc.target/i386/pr54703.c new file mode 100644 index 000000000000..e30c293c0766 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr54703.c @@ -0,0 +1,36 @@ +/* PR target/54703 */ +/* { dg-do run { target sse2_runtime } } */ +/* { dg-options "-O -msse2" } */ +/* { dg-additional-options "-mavx -mtune=bdver1" { target avx_runtime } } */ + +extern void abort (void); +typedef double V __attribute__((vector_size(16))); + +union { + unsigned long long m[2]; + V v; +} u = { { 0xffffffffff000000ULL, 0xffffffffff000000ULL } }; + +static inline V +foo (V x) +{ + V y = __builtin_ia32_andpd (x, u.v); + V z = __builtin_ia32_subpd (x, y); + return __builtin_ia32_mulpd (y, z); +} + +void +test (V *x) +{ + V a = { 2.1, 2.1 }; + *x = foo (foo (a)); +} + +int +main () +{ + test (&u.v); + if (u.m[0] != 0x3acbf487f0a30550ULL || u.m[1] != u.m[0]) + abort (); + return 0; +}