Bug 88514 - [9 Regression] FAIL: gcc.target/i386/avx512vl-pr79299-1.c (internal compiler error)
Summary: [9 Regression] FAIL: gcc.target/i386/avx512vl-pr79299-1.c (internal compiler ...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 9.0
: P3 normal
Target Milestone: 9.0
Assignee: Jakub Jelinek
URL:
Keywords:
: 88513 88519 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-12-15 17:43 UTC by H.J. Lu
Modified: 2018-12-18 11:24 UTC (History)
3 users (show)

See Also:
Host:
Target: i386, x86-64
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-12-15 00:00:00


Attachments
gcc9-pr88514-wip.patch (1.39 KB, patch)
2018-12-16 16:21 UTC, Jakub Jelinek
Details | Diff
gcc9-pr88514-wip.patch (2.25 KB, patch)
2018-12-17 13:33 UTC, Jakub Jelinek
Details | Diff
gcc9-pr88513.patch (5.65 KB, patch)
2018-12-17 18:41 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2018-12-15 17:43:23 UTC
On x86-64 with -march=skylake-avx512, r267170 gave

FAIL: gcc.target/i386/avx512vl-pr79299-1.c (internal compiler error)
Comment 1 H.J. Lu 2018-12-15 19:45:44 UTC
This is caused by r267097.
Comment 2 Jakub Jelinek 2018-12-15 23:42:05 UTC
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).
Comment 3 Jakub Jelinek 2018-12-16 16:21:48 UTC
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.
Comment 4 Jakub Jelinek 2018-12-17 13:33:44 UTC
Created attachment 45246 [details]
gcc9-pr88514-wip.patch

Updated WIP patch.
Comment 5 Jakub Jelinek 2018-12-17 18:41:49 UTC
Created attachment 45248 [details]
gcc9-pr88513.patch

Full untested patch.
Comment 6 Jakub Jelinek 2018-12-18 08:46:27 UTC
*** Bug 88519 has been marked as a duplicate of this bug. ***
Comment 7 Jakub Jelinek 2018-12-18 08:46:58 UTC
*** Bug 88513 has been marked as a duplicate of this bug. ***
Comment 8 Jakub Jelinek 2018-12-18 11:22:32 UTC
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
Comment 9 Jakub Jelinek 2018-12-18 11:24:05 UTC
Should be fixed now.