https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127784
Bug ID: 127784
Summary: [17 Regression] ICE: verify_gimple failed with
unmasked call of "omp declare simd inbranch" clone
since r17-2654
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: igor at tachyum dot com
Target Milestone: ---
Created attachment 65786
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=65786&action=edit
testcase to demo the problem
The attached testcase ICEs on x86_64 trunk (r17-4942) with -O2 -fopenmp-simd;
-m32, -O3, -march=x86-64-v2 and -mavx512f ICE the same way. GCC 16.2 compiles
it (also with -fchecking) and the program runs correctly.
$ gcc -O2 -fopenmp-simd -S simd-clone-inbranch.c
simd-clone-inbranch.c: In function 'f':
simd-clone-inbranch.c:16:1: error: the first argument of a 'vec_cond_expr'
must be of a boolean vector type of the same number of elements as the result
vector(2) double
vector(2) double
_38 = VEC_COND_EXPR <vect_cst__39, { 1.0e+0, 1.0e+0 }, { 0.0, 0.0 }>;
during GIMPLE pass: slp
simd-clone-inbranch.c:16:1: internal compiler error: verify_gimple failed
Started with r17-2654 (fb0838bc107, "Support two-lane vector BB reductions
without target support"), which lets the two foo () calls be SLP-vectorized
as one call of the inbranch SSE clone at a call site that is not masked.
The underlying bug is older and in vectorizable_simd_clone_call: for an
inbranch clone used unmasked it builds an all-true mask with
vect_build_all_ones_mask and, when the clone's mask_mode is VOIDmode (the
mask argument is a vector of the argument type, here vector(2) double),
converts it to the clone's 1/0 encoding with
VEC_COND_EXPR <mask, { 1, ... }, { 0, ... }>. vect_build_all_ones_mask
returns a boolean vector only for a boolean mask type; for vector(2) double
it is a vector of NaNs, so the VEC_COND_EXPR condition is invalid.
Since all lanes are active, passing the vector of 1s directly avoids the
VEC_COND_EXPR. Patch to follow.