On x86-64 with -march=skylake-avx512, r267170 gave FAIL: gcc.target/i386/avx512vl-pr79299-1.c (internal compiler error)
This is caused by r267097.
I think the ICE is for the same reason as why we don't vectorize: int a[1024]; short int b[1024]; long long c[1024]; void baz (void) { for (int i = 0; i < 1024; i++) if (a[i] > 10) c[i] = 5; } with -O3 -mavx512{bw,vl,dq} -mprefer-vector-width=256 (or 128). Unlike the code I've added which uses VEC_{LO,HI}_UNPACK_EXPR on the boolean vectors directly, vectorizable_conversion checks supportable_widening_operation and fails because for the vectype_in vector(8) bool and vectype_out vector(4) bool it can't find an optab. We have vec_unpacks_{lo,hi}_{hi,si,di} optabs that cover vector(64) bool -> vector(32) bool, vector(32) bool -> vector(16) bool and vector(16) bool -> vector(8) bool operations. If we added vec_unpacks_{lo,hi}_qi, it would be ambiguous, whether it is vector(8) bool -> vector(4) bool or vector(4) bool -> vector(2) bool, so wonder whether we need a new optab or pass some extra argument to the optab which would tell it the nunits. The operations we are looking for is really a nop for vec_unpacks_lo_qi (so actually don't care about the nunits), the 8 or 4 bit bool vector (mask) has the right bits in the bottom bits, but we need to use a different shift for vec_unpacks_hi_qi (either kshiftr{w,b} $4, %kN, %kM or kshiftr{w,b} $2, %kN, %kM).
Created attachment 45245 [details] gcc9-pr88514-wip.patch Untested WIP patch. With this I can vectorize the above testcase fine, but the testcase in #c0 still ICEs, just with a different ICE.
Created attachment 45246 [details] gcc9-pr88514-wip.patch Updated WIP patch.
Created attachment 45248 [details] gcc9-pr88513.patch Full untested patch.
*** Bug 88519 has been marked as a duplicate of this bug. ***
*** Bug 88513 has been marked as a duplicate of this bug. ***
Author: jakub Date: Tue Dec 18 11:22:00 2018 New Revision: 267228 URL: https://gcc.gnu.org/viewcvs?rev=267228&root=gcc&view=rev Log: PR target/88513 PR target/88514 * optabs.def (vec_pack_sbool_trunc_optab, vec_unpacks_sbool_hi_optab, vec_unpacks_sbool_lo_optab): New optabs. * optabs.c (expand_widen_pattern_expr): Use vec_unpacks_sbool_*_optab and pass additional argument if both input and target have the same scalar mode of VECTOR_BOOLEAN_TYPE_P vectors. * expr.c (expand_expr_real_2) <case VEC_PACK_TRUNC_EXPR>: Handle VECTOR_BOOLEAN_TYPE_P pack where result has the same scalar mode as the operands using vec_pack_sbool_trunc_optab. * tree-vect-stmts.c (supportable_widening_operation): Use vec_unpacks_sbool_{lo,hi}_optab for VECTOR_BOOLEAN_TYPE_P conversions where both wider_vectype and vectype have the same scalar mode. (supportable_narrowing_operation): Similarly use vec_pack_sbool_trunc_optab if narrow_vectype and vectype have the same scalar mode. * config/i386/i386.c (ix86_get_builtin) <case IX86_BUILTIN_GATHER3ALTDIV8SF>: Check for VECTOR_MODE_P rather than non-VOIDmode. * config/i386/sse.md (vec_pack_trunc_qi, vec_pack_trunc_<mode>): Remove useless ()s around "register_operand", formatting fixes. (vec_pack_sbool_trunc_qi, vec_unpacks_sbool_lo_qi, vec_unpacks_sbool_hi_qi): New expanders. * doc/md.texi (vec_pack_sbool_trunc_M, vec_unpacks_sbool_hi_M, vec_unpacks_sbool_lo_M): Document. * gcc.target/i386/avx512f-pr88513-1.c: New test. * gcc.target/i386/avx512f-pr88513-2.c: New test. * gcc.target/i386/avx512vl-pr88464-1.c: New test. * gcc.target/i386/avx512vl-pr88464-2.c: New test. * gcc.target/i386/avx512vl-pr88464-3.c: New test. * gcc.target/i386/avx512vl-pr88464-4.c: New test. * gcc.target/i386/avx512vl-pr88513-1.c: New test. * gcc.target/i386/avx512vl-pr88513-2.c: New test. * gcc.target/i386/avx512vl-pr88513-3.c: New test. * gcc.target/i386/avx512vl-pr88513-4.c: New test. * gcc.target/i386/avx512vl-pr88514-1.c: New test. * gcc.target/i386/avx512vl-pr88514-2.c: New test. * gcc.target/i386/avx512vl-pr88514-3.c: New test. Added: trunk/gcc/testsuite/gcc.target/i386/avx512f-pr88513-1.c trunk/gcc/testsuite/gcc.target/i386/avx512f-pr88513-2.c trunk/gcc/testsuite/gcc.target/i386/avx512vl-pr88464-1.c trunk/gcc/testsuite/gcc.target/i386/avx512vl-pr88464-2.c trunk/gcc/testsuite/gcc.target/i386/avx512vl-pr88464-3.c trunk/gcc/testsuite/gcc.target/i386/avx512vl-pr88464-4.c trunk/gcc/testsuite/gcc.target/i386/avx512vl-pr88513-1.c trunk/gcc/testsuite/gcc.target/i386/avx512vl-pr88513-2.c trunk/gcc/testsuite/gcc.target/i386/avx512vl-pr88513-3.c trunk/gcc/testsuite/gcc.target/i386/avx512vl-pr88513-4.c trunk/gcc/testsuite/gcc.target/i386/avx512vl-pr88514-1.c trunk/gcc/testsuite/gcc.target/i386/avx512vl-pr88514-2.c trunk/gcc/testsuite/gcc.target/i386/avx512vl-pr88514-3.c Modified: trunk/gcc/ChangeLog trunk/gcc/config/i386/i386.c trunk/gcc/config/i386/sse.md trunk/gcc/doc/md.texi trunk/gcc/expr.c trunk/gcc/optabs.c trunk/gcc/optabs.def trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-vect-stmts.c
Should be fixed now.