aarch64: Fix ICE when expanding scalar floating move with -mgeneral-regs-only. [PR94991]
authorFei Yang <felix.yang@huawei.com>
Mon, 11 May 2020 14:18:47 +0000 (15:18 +0100)
committerRichard Sandiford <richard.sandiford@arm.com>
Mon, 11 May 2020 14:18:47 +0000 (15:18 +0100)
In the testcase for PR94991, we are doing FAIL for scalar floating move expand
pattern since TARGET_FLOAT is false with option -mgeneral-regs-only. But move
expand pattern cannot fail. It would be better to replace the FAIL with code
that bitcasts to the equivalent integer mode using gen_lowpart.

2020-05-11  Felix Yang  <felix.yang@huawei.com>

gcc/
PR target/94991
* config/aarch64/aarch64.md (mov<mode>):
Bitcasts to the equivalent integer mode using gen_lowpart
instead of doing FAIL for scalar floating point move.

gcc/testsuite/
PR target/94991
* gcc.target/aarch64/mgeneral-regs_5.c: New test.

gcc/ChangeLog
gcc/config/aarch64/aarch64.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/aarch64/mgeneral-regs_5.c [new file with mode: 0644]

index c4856f4..ae022d5 100644 (file)
@@ -1,3 +1,10 @@
+2020-05-11  Felix Yang  <felix.yang@huawei.com>
+
+       PR target/94991
+       * config/aarch64/aarch64.md (mov<mode>):
+       Bitcasts to the equivalent integer mode using gen_lowpart
+       instead of doing FAIL for scalar floating point move.
+
 2020-05-11  Alex Coplan  <alex.coplan@arm.com>
 
        * config/aarch64/aarch64.c (aarch64_if_then_else_costs): Add case
index b2cfd01..deca000 100644 (file)
     if (!TARGET_FLOAT)
       {
        aarch64_err_no_fpadvsimd (<MODE>mode);
-       FAIL;
+       machine_mode intmode
+         = int_mode_for_size (GET_MODE_BITSIZE (<MODE>mode), 0).require ();
+       emit_move_insn (gen_lowpart (intmode, operands[0]),
+                       gen_lowpart (intmode, operands[1]));
+       DONE;
       }
 
     if (GET_CODE (operands[0]) == MEM
index ac40f2e..6484633 100644 (file)
@@ -1,3 +1,8 @@
+2020-05-11  Felix Yang  <felix.yang@huawei.com>
+
+       PR target/94991
+       * gcc.target/aarch64/mgeneral-regs_5.c: New test.
+
 2020-05-11  Alex Coplan  <alex.coplan@arm.com>
 
        * gcc.target/aarch64/csinv-neg.c: New test.
diff --git a/gcc/testsuite/gcc.target/aarch64/mgeneral-regs_5.c b/gcc/testsuite/gcc.target/aarch64/mgeneral-regs_5.c
new file mode 100644 (file)
index 0000000..589509a
--- /dev/null
@@ -0,0 +1,14 @@
+/* { dg-options "-mgeneral-regs-only -O2" } */
+
+struct S { float d; };
+
+void bar (struct S);
+
+void
+f0 (int x)
+{
+  struct S s = { .d = 0.0f }; /* { dg-error "'-mgeneral-regs-only' is incompatible with the use of floating-point types" } */
+  ((char *) &s.d)[0] = x;
+  s.d *= 7.0; /* { dg-error "'-mgeneral-regs-only' is incompatible with the use of floating-point types" } */
+  bar (s); /* { dg-error "'-mgeneral-regs-only' is incompatible with the use of floating-point types" } */
+}