From ca7584f79af7aa544f72a0d599020d72e06639e6 Mon Sep 17 00:00:00 2001 From: Pat Haugen Date: Thu, 17 May 2018 16:19:16 +0000 Subject: [PATCH] re PR tree-optimization/85698 (CPU2017 525.x264_r fails starting with r257581) PR target/85698 * config/rs6000/rs6000.c (rs6000_output_move_128bit): Check dest operand. * gcc.target/powerpc/pr85698.c: New test. Co-Authored-By: Segher Boessenkool From-SVN: r260329 --- gcc/ChangeLog | 7 ++ gcc/config/rs6000/rs6000.c | 2 +- gcc/testsuite/ChangeLog | 5 ++ gcc/testsuite/gcc.target/powerpc/pr85698.c | 79 ++++++++++++++++++++++ 4 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/powerpc/pr85698.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3c59e090972..2ec4a568346 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2018-05-17 Pat Haugen + Segher Boessenkool + + PR target/85698 + * config/rs6000/rs6000.c (rs6000_output_move_128bit): Check dest + operand. + 2018-05-17 Richard Biener * tree-ssa-dse.c (dse_classify_store): Fix iterator increment diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index c5b3a133318..877d6bae5ad 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -20234,7 +20234,7 @@ rs6000_output_move_128bit (rtx operands[]) } else if (TARGET_ALTIVEC && src_vmx_p - && altivec_indexed_or_indirect_operand (src, mode)) + && altivec_indexed_or_indirect_operand (dest, mode)) return "stvx %1,%y0"; else if (TARGET_VSX && src_vsx_p) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2139976c9f0..2dd034016c0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-05-17 Pat Haugen + + PR target/85698 + * gcc.target/powerpc/pr85698.c: New test. + 2018-05-17 Richard Biener * gcc.dg/tree-ssa/ssa-fre-63.c: New testcase. diff --git a/gcc/testsuite/gcc.target/powerpc/pr85698.c b/gcc/testsuite/gcc.target/powerpc/pr85698.c new file mode 100644 index 00000000000..294a5665b32 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr85698.c @@ -0,0 +1,79 @@ +/* { dg-do run } */ +/* { dg-require-effective-target vsx_hw } */ +/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power7" } } */ +/* { dg-options "-O3 -mcpu=power7" } */ + +/* PR85698: Incorrect code generated on LE due to use of stxvw4x. */ + +typedef unsigned char uint8_t; +typedef short int16_t; +extern void abort (void); +extern int memcmp(const void *, const void *, __SIZE_TYPE__); + +uint8_t expected[128] = +{14, 0, 4, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 28, 35, 33, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 66, 63, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, + 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 97, 96, + 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, + 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127}; + +static uint8_t x264_clip_uint8( int x ) +{ + return x&(~255) ? (-x)>>31 : x; +} +void add4x4_idct( uint8_t *p_dst, int16_t dct[16]) +{ + int16_t d[16]; + int16_t tmp[16]; + int i, y, x; + for( i = 0; i < 4; i++ ) + { + int s02 = dct[0*4+i] + dct[2*4+i]; + int d02 = dct[0*4+i] - dct[2*4+i]; + int s13 = dct[1*4+i] + (dct[3*4+i]>>1); + int d13 = (dct[1*4+i]>>1) - dct[3*4+i]; + tmp[i*4+0] = s02 + s13; + tmp[i*4+1] = d02 + d13; + tmp[i*4+2] = d02 - d13; + tmp[i*4+3] = s02 - s13; + } + for( i = 0; i < 4; i++ ) + { + int s02 = tmp[0*4+i] + tmp[2*4+i]; + int d02 = tmp[0*4+i] - tmp[2*4+i]; + int s13 = tmp[1*4+i] + (tmp[3*4+i]>>1); + int d13 = (tmp[1*4+i]>>1) - tmp[3*4+i]; + d[0*4+i] = ( s02 + s13 + 32 ) >> 6; + d[1*4+i] = ( d02 + d13 + 32 ) >> 6; + d[2*4+i] = ( d02 - d13 + 32 ) >> 6; + d[3*4+i] = ( s02 - s13 + 32 ) >> 6; + } + for( y = 0; y < 4; y++ ) + { + for( x = 0; x < 4; x++ ) + p_dst[x] = x264_clip_uint8( p_dst[x] + d[y*4+x] ); + p_dst += 32; + } +} + +int main() +{ + uint8_t dst[128]; + int16_t dct[16]; + int i; + + for (i = 0; i < 16; i++) + dct[i] = i*10 + i; + for (i = 0; i < 128; i++) + dst[i] = i; + + add4x4_idct(dst, dct); + + if (memcmp (dst, expected, 128)) + abort(); + + return 0; +} + -- 2.30.2