On Tue, 9 Sep 2025, Alex Coplan wrote:

> Hi,
> 
> In this PR we have a reduction of a vector constructor, where the
> type of the constructor is int16x8_t and the elements are int16x4_t;
> i.e. it is representing a concatenation of two vectors.
> 
> This triggers a match.pd pattern which looks like it was written to
> handle reductions of vector constructors where the elements of the ctor
> are scalars, not vectors.  There is no type check to enforce this
> property, which leads to the pattern replacing a reduction to scalar
> with an int16x4_t vector in this case, which of course is a type error,
> leading to an invalid GIMPLE ICE.
> 
> This patch adds a type check to the pattern, only going ahead with the
> transformation if the element type of the ctor matches that of the
> reduction.
> 
> Bootstrapped/regtested on aarch64-linux-gnu and x86_64-linux-gnu.

OK for trunk and branches.

Richard.

> OK for trunk?  What about backports?  The offending match.pd pattern was
> introduced in r12-7326-g2ef0e75d0bbc80 but the ICE can only be
> reproduced with the given testcase starting with
> r13-1836-g8a1e05b7618fed (when we started lowering vcombine to GIMPLE in
> the aarch64 backend).  Not sure how easy it would be to construct a
> generic testcase since AFAIK we don't expose a general vector concat
> operation on GCC vectors.  So I suppose we can either backport to 13 and
> stop there or backport to 12 without a testcase (assuming a suitable one
> can't be crafted).
> 
> Thanks,
> Alex
> 
> gcc/ChangeLog:
> 
>       PR tree-optimization/121772
>       * match.pd: Add type check to reduc(ctor) pattern.
> 
> gcc/testsuite/ChangeLog:
> 
>       PR tree-optimization/121772
>       * gcc.target/aarch64/torture/pr121772.c: New test.
> 

-- 
Richard Biener <rguent...@suse.de>
SUSE Software Solutions Germany GmbH,
Frankenstrasse 146, 90461 Nuernberg, Germany;
GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)

Reply via email to