gcc/optabs-Dont-use-scalar-conversions-for-vectors.patch
xiezhiheng ae8eb7c877 [Upload patch] Upload patches to add new features
and fix bugs

- add-fp-model-options.patch: New file
- enable-simd-math.patch: Enable simd math library in C and Fortran
- fix-CTOR-vectorization.patch: New file
- fix-range-set-by-vectorization-on-niter-IVs.patch: New file
- medium-code-mode.patch: Fix bugs when used with fpic
- optabs-Dont-use-scalar-conversions-for-vectors.patch: New file
- PR92429-do-not-fold-when-updating.patch: New file
- redundant-loop-elimination.patch: Fix some programming specifications
- fix-ICE-in-vect.patch: New file
- Fix-type-mismatch-in-SLPed-constructors.patch: New file
- add-check-for-pressure-in-sche1.patch: New file
- revert-moutline-atomics.patch: New file
- fix-ICE-in-eliminate-stmt.patch: New file
- revise-type-before-build-MULT.patch: New file
- Simplify-X-C1-C2.patch: New file
- gcc.spec: Add new patches
2021-04-29 10:30:11 +08:00

70 lines
1.7 KiB
Diff

This backport contains 1 patch from gcc main stream tree.
The commit id of these patchs list as following in the order of time.
0001-optabs-Don-t-use-scalar-conversions-for-vectors-PR93.patch
b6268016bf46dd63227dcbb73d13c30a3b4b9d2a
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/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();
+}