internal-fn: Avoid dropping the lhs of some calls [PR94941]
authorRichard Sandiford <richard.sandiford@arm.com>
Mon, 4 May 2020 20:21:16 +0000 (21:21 +0100)
committerRichard Sandiford <richard.sandiford@arm.com>
Mon, 4 May 2020 20:21:16 +0000 (21:21 +0100)
commit3af3bec2e4d344bd54a134d8b2263f44d788c3d8
treeea524b0518b71db3bad2814aa46daea9f4089e50
parent0719055a956d900f160e2e980eb2a5c8bcc7cb39
internal-fn: Avoid dropping the lhs of some calls [PR94941]

create_output_operand coerces an output operand to the insn's
predicates, using a suggested rtx location if convenient.
But if that rtx location is actually required rather than
optional, the builder of the insn has to emit a move afterwards.

(We could instead add a new interface that does this automatically,
but that's future work.)

This PR shows that we were failing to emit the move for some of the
vector load internal functions.  I think there are other routines in
internal-fn.c that potentially have the same problem, but this patch is
supposed to be a conservative subset suitable for backporting to GCC 10.

2020-05-04  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
PR middle-end/94941
* internal-fn.c (expand_load_lanes_optab_fn): Emit a move if the
chosen lhs is different from the gcall lhs.
(expand_mask_load_optab_fn): Likewise.
(expand_gather_load_optab_fn): Likewise.

gcc/testsuite/
PR middle-end/94941
* gcc.target/aarch64/sve/acle/general/unoptimized_1.c: New test.
gcc/ChangeLog
gcc/internal-fn.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/aarch64/sve/acle/general/unoptimized_1.c [new file with mode: 0644]