]> gcc.gnu.org Git - gcc.git/commit
middle-end/104497 - gimplification of vector indexing
authorRichard Biener <rguenther@suse.de>
Fri, 11 Feb 2022 10:08:57 +0000 (11:08 +0100)
committerRichard Biener <rguenther@suse.de>
Thu, 7 Apr 2022 09:14:48 +0000 (11:14 +0200)
commitd34083a16b51c85b49092b0a5d9d444750f32134
tree0cd7413b700dc27fc4418c928ca29248565ce2ee
parent825151e16373760527678df8ad524bd725e36c7b
middle-end/104497 - gimplification of vector indexing

The following attempts to address gimplification of

   ... = VIEW_CONVERT_EXPR<int[4]>((i & 1) != 0 ? inv : src)[i];

which is problematic since gimplifying the base object
? inv : src produces a register temporary but GIMPLE does not
really support a register as a base for an ARRAY_REF (even
though that's not strictly validated it seems as can be seen
at -O0).  Interestingly the C++ frontend avoids this issue
by emitting the following GENERIC instead:

   ... = (i & 1) != 0 ? VIEW_CONVERT_EXPR<int[4]>(inv)[i] : VIEW_CONVERT_EXPR<int[4]>(src)[i];

The proposed patch below fixes things up when using an rvalue
as the base is OK by emitting a copy from a register base to a
non-register one.  The ?: as lvalue extension seems to be gone
for C, C++ again unwraps the COND_EXPR in that case.

2022-02-11  Richard Biener  <rguenther@suse.de>

PR middle-end/104497
* gimplify.c (gimplify_compound_lval): Make sure the
base is a non-register if needed and possible.

* c-c++-common/torture/pr104497.c: New testcase.
gcc/gimplify.c
gcc/testsuite/c-c++-common/torture/pr104497.c [new file with mode: 0644]
This page took 0.062574 seconds and 6 git commands to generate.