]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
aarch64: force operand to fresh register to avoid subreg issues [PR118892]
authorTamar Christina <tamar.christina@arm.com>
Tue, 4 Mar 2025 11:15:26 +0000 (11:15 +0000)
committerTamar Christina <tamar.christina@arm.com>
Tue, 4 Mar 2025 11:15:52 +0000 (11:15 +0000)
When the input is already a subreg and we try to make a paradoxical
subreg out of it for copysign this can fail if it violates the subreg
relationship.

Use force_lowpart_subreg instead of lowpart_subreg to then force the
results to a register instead of ICEing.

gcc/ChangeLog:

PR target/118892
* config/aarch64/aarch64.md (copysign<GPF:mode>3): Use
force_lowpart_subreg instead of lowpart_subreg.

gcc/testsuite/ChangeLog:

PR target/118892
* gcc.target/aarch64/copysign-pr118892.c: New test.

gcc/config/aarch64/aarch64.md
gcc/testsuite/gcc.target/aarch64/copysign-pr118892.c [new file with mode: 0644]

index cfe730f3732ce45c914b30a908851a4a7dd77c0f..b10059e4f5808b42e97dd6c4d5dd32c913fcf242 100644 (file)
     {
       emit_insn (gen_ior<vq_int_equiv>3 (
        lowpart_subreg (<VQ_INT_EQUIV>mode, operands[0], <MODE>mode),
-       lowpart_subreg (<VQ_INT_EQUIV>mode, operands[1], <MODE>mode),
+       force_lowpart_subreg (<VQ_INT_EQUIV>mode, operands[1], <MODE>mode),
        v_bitmask));
       DONE;
     }
diff --git a/gcc/testsuite/gcc.target/aarch64/copysign-pr118892.c b/gcc/testsuite/gcc.target/aarch64/copysign-pr118892.c
new file mode 100644 (file)
index 0000000..adfa30d
--- /dev/null
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-Ofast" } */
+
+double l();
+double f()
+{
+  double t6[2] = {l(), l()};
+  double t7[2];
+  __builtin_memcpy(&t7, &t6, sizeof(t6));
+  return -__builtin_fabs(t7[1]);
+}