From 9b5ee426fcfe9d473edff34cd65f99c057799d7d Mon Sep 17 00:00:00 2001 From: Bill Schmidt Date: Tue, 10 May 2016 14:27:12 +0000 Subject: [PATCH] re PR target/70963 (vec_cts/vec_ctf intrinsics produce wrong results for 64-bit floating point) [gcc] 2016-05-10 Bill Schmidt PR target/70963 * config/rs6000/vsx.md (vsx_xvcvdpsxds_scale): Generate correct code for a zero scale factor. (vsx_xvcvdpuxds_scale): Likewise. [gcc/testsuite] 2016-05-10 Bill Schmidt PR target/70963 * gcc.target/powerpc/pr70963.c: New. From-SVN: r236082 --- gcc/ChangeLog | 7 ++++ gcc/config/rs6000/vsx.md | 26 +++++++++---- gcc/testsuite/ChangeLog | 5 +++ gcc/testsuite/gcc.target/powerpc/pr70963.c | 43 ++++++++++++++++++++++ 4 files changed, 73 insertions(+), 8 deletions(-) create mode 100644 gcc/testsuite/gcc.target/powerpc/pr70963.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cab5f40aef0..eaa91286153 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2016-05-10 Bill Schmidt + + PR target/70963 + * config/rs6000/vsx.md (vsx_xvcvdpsxds_scale): Generate correct + code for a zero scale factor. + (vsx_xvcvdpuxds_scale): Likewise. + 2016-05-10 David Malcolm * diagnostic-show-locus.c (layout::layout): Call show_ruler diff --git a/gcc/config/rs6000/vsx.md b/gcc/config/rs6000/vsx.md index 508eeacd3a4..1d6e4797d7c 100644 --- a/gcc/config/rs6000/vsx.md +++ b/gcc/config/rs6000/vsx.md @@ -1717,10 +1717,15 @@ { rtx op0 = operands[0]; rtx op1 = operands[1]; - rtx tmp = gen_reg_rtx (V2DFmode); - int scale = INTVAL(operands[2]); - if (scale != 0) - rs6000_scale_v2df (tmp, op1, scale); + rtx tmp; + int scale = INTVAL (operands[2]); + if (scale == 0) + tmp = op1; + else + { + tmp = gen_reg_rtx (V2DFmode); + rs6000_scale_v2df (tmp, op1, scale); + } emit_insn (gen_vsx_xvcvdpsxds (op0, tmp)); DONE; }) @@ -1741,10 +1746,15 @@ { rtx op0 = operands[0]; rtx op1 = operands[1]; - rtx tmp = gen_reg_rtx (V2DFmode); - int scale = INTVAL(operands[2]); - if (scale != 0) - rs6000_scale_v2df (tmp, op1, scale); + rtx tmp; + int scale = INTVAL (operands[2]); + if (scale == 0) + tmp = op1; + else + { + tmp = gen_reg_rtx (V2DFmode); + rs6000_scale_v2df (tmp, op1, scale); + } emit_insn (gen_vsx_xvcvdpuxds (op0, tmp)); DONE; }) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c1a2135bfb5..58d0c8db438 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-05-10 Bill Schmidt + + PR target/70963 + * gcc.target/powerpc/pr70963.c: New. + 2016-05-10 David Malcolm * gcc.dg/plugin/diagnostic-test-show-locus-bw.c diff --git a/gcc/testsuite/gcc.target/powerpc/pr70963.c b/gcc/testsuite/gcc.target/powerpc/pr70963.c new file mode 100644 index 00000000000..b5d8316b722 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr70963.c @@ -0,0 +1,43 @@ +/* { dg-do run { target { powerpc64*-*-* && vsx_hw } } } */ +/* { dg-require-effective-target powerpc_vsx_ok } */ +/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */ +/* { dg-options "-maltivec" } */ + +#include +#include +#include + +static int failed; +static void test (void); + +static void check (int result, const char *name) +{ + if (!result) + { + failed++; + printf ("fail %s\n", name); + } +} + +int main (void) +{ + test (); + if (failed) + abort (); + return 0; +} + +vector double x = { 81.0, 76.0 }; +vector long long y = { 81, 76 }; + +static void test() +{ + vector long long a = vec_cts (x, 0); + vector double b = vec_ctf (a, 0); + vector long long c = __builtin_vsx_xvcvdpuxds_scale (x, 0); + vector double d = vec_ctf (c, 0); + check (vec_all_eq (a, y), "vec_cts"); + check (vec_all_eq (b, x), "vec_ctf"); + check (vec_all_eq (c, y), "xvcvdpuxds"); + check (vec_all_eq (d, x), "vec_ctf unsigned"); +} -- 2.30.2