From: Richard Sandiford Date: Tue, 25 Feb 2020 19:20:58 +0000 (+0000) Subject: optabs: Don't use scalar conversions for vectors [PR93843] X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b6268016bf46dd63227dcbb73d13c30a3b4b9d2a;p=gcc.git optabs: Don't use scalar conversions for vectors [PR93843] In this PR we had a conversion between two integer vectors that both had scalar integer modes. We then tried to implement the conversion using the scalar optab for those modes, instead of doing the conversion elementwise. I wondered about letting through scalar modes for single-element vectors, but I don't have any evidence that that's useful/necessary, so it seemed better to keep things simple. 2020-02-26 Richard Sandiford gcc/ PR middle-end/93843 * optabs-tree.c (supportable_convert_operation): Reject types with scalar modes. gcc/testsuite/ PR middle-end/93843 * gcc.dg/vect/pr93843-1.c: New test. * gcc.dg/vect/pr93843-2.c: Likewise. --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7504b130222..c5b1eccb7d6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2020-02-26 Richard Sandiford + + PR middle-end/93843 + * optabs-tree.c (supportable_convert_operation): Reject types with + scalar modes. + 2020-02-26 David Malcolm * Makefile.in (ANALYZER_OBJS): Add analyzer/bar-chart.o. diff --git a/gcc/optabs-tree.c b/gcc/optabs-tree.c index 3d829c27826..badd30bfda8 100644 --- a/gcc/optabs-tree.c +++ b/gcc/optabs-tree.c @@ -284,9 +284,14 @@ supportable_convert_operation (enum tree_code code, machine_mode m1,m2; bool truncp; + gcc_assert (VECTOR_TYPE_P (vectype_out) && VECTOR_TYPE_P (vectype_in)); + m1 = TYPE_MODE (vectype_out); m2 = TYPE_MODE (vectype_in); + if (!VECTOR_MODE_P (m1) || !VECTOR_MODE_P (m2)) + return false; + /* First check if we can done conversion directly. */ if ((code == FIX_TRUNC_EXPR && can_fix_p (m1,m2,TYPE_UNSIGNED (vectype_out), &truncp) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 35715adbe52..aa5d41e5559 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2020-02-26 Richard Sandiford + + PR middle-end/93843 + * gcc.dg/vect/pr93843-1.c: New test. + * gcc.dg/vect/pr93843-2.c: Likewise. + 2020-02-26 Jakub Jelinek PR tree-optimization/93820 diff --git a/gcc/testsuite/gcc.dg/vect/pr93843-1.c b/gcc/testsuite/gcc.dg/vect/pr93843-1.c new file mode 100644 index 00000000000..23a79ca4c96 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr93843-1.c @@ -0,0 +1,21 @@ +char a; +struct S { short b, c; } d; + +__attribute__((noipa)) void +foo (int x) +{ + if (x != 4) + __builtin_abort (); +} + +int +main () +{ + short *g = &d.c, *h = &d.b; + char e = 4 - a; + int f; + *h = *g = e; + for (f = 0; f < 2; f++) + foo (d.c); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/vect/pr93843-2.c b/gcc/testsuite/gcc.dg/vect/pr93843-2.c new file mode 100644 index 00000000000..5fae3e5be17 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr93843-2.c @@ -0,0 +1,11 @@ +char in[2] = {2, 2}; +short out[2] = {}; + +int +main() +{ + for (int i = 0; i < 2; ++i) + out[i] = in[i]; + asm("":::"memory"); + if (out[0] != 2) __builtin_abort(); +}