]> 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>
Mon, 28 Apr 2025 11:58:37 +0000 (12:58 +0100)
committerTamar Christina <tamar.christina@arm.com>
Mon, 28 Apr 2025 11:58:37 +0000 (12:58 +0100)
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 95577b325cef9f6fd3f997c671935e28ef378e1a..6a481059bf086e923c1433d128b9b6a1182c615b 100644 (file)
 
       emit_insn (gen_iorv2<v_int_equiv>3 (
        lowpart_subreg (V2<V_INT_EQUIV>mode, operands[0], <MODE>mode),
-       lowpart_subreg (V2<V_INT_EQUIV>mode, operands[1], <MODE>mode),
+       force_lowpart_subreg (V2<V_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]);
+}