This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Avoid ICE in PR82713
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 19 Nov 2017 19:54:02 +0100
- Subject: Avoid ICE in PR82713
- Authentication-results: sourceware.org; auth=none
Hi,
this patch implements Richi's suggestion to not ICE when vectorization
costmodel is asked for cost of vector load/store that is not of vector
type.
Bootstrapped/regtsted x86_64-linux, comitted.
PR target/82713
* i386.c (ix86_builtin_vectorization_cost): Be ready for insane
types.
Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c (revision 254929)
+++ config/i386/i386.c (working copy)
@@ -44628,13 +44628,18 @@ ix86_builtin_vectorization_cost (enum ve
case vector_load:
index = sse_store_index (mode);
- gcc_assert (index >= 0);
+ /* See PR82713 - we may end up being called on non-vector type. */
+ if (index < 0)
+ index = 2;
return ix86_vec_cost (mode,
COSTS_N_INSNS (ix86_cost->sse_load[index]) / 2,
true);
case vector_store:
index = sse_store_index (mode);
+ /* See PR82713 - we may end up being called on non-vector type. */
+ if (index < 0)
+ index = 2;
return ix86_vec_cost (mode,
COSTS_N_INSNS (ix86_cost->sse_store[index]) / 2,
true);
@@ -44647,6 +44652,9 @@ ix86_builtin_vectorization_cost (enum ve
Do that incrementally. */
case unaligned_load:
index = sse_store_index (mode);
+ /* See PR82713 - we may end up being called on non-vector type. */
+ if (index < 0)
+ index = 2;
return ix86_vec_cost (mode,
COSTS_N_INSNS
(ix86_cost->sse_unaligned_load[index]) / 2,
@@ -44654,6 +44662,9 @@ ix86_builtin_vectorization_cost (enum ve
case unaligned_store:
index = sse_store_index (mode);
+ /* See PR82713 - we may end up being called on non-vector type. */
+ if (index < 0)
+ index = 2;
return ix86_vec_cost (mode,
COSTS_N_INSNS
(ix86_cost->sse_unaligned_store[index]) / 2,
Index: testsuite/gcc.target/i386/pr82713.c
===================================================================
--- testsuite/gcc.target/i386/pr82713.c (revision 0)
+++ testsuite/gcc.target/i386/pr82713.c (working copy)
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+* { dg-options "-O3 -mavx512bw" } */
+
+_Bool a[2048];
+int b[2048];
+
+void
+foo ()
+{
+ int i;
+ for (i = 0; i < 2048; i += 4)
+ {
+ a[i] = b[i] <= 10;
+ a[i + 3] = b[i + 1] <= 10;
+ a[i + 2] = b[i + 2] <= 10;
+ a[i + 1] = b[i + 3] <= 10;
+ }
+}
+