i386: Disable *<absneg:code><mode>2_i387_1 for TARGET_SSE_MATH modes
authorUros Bizjak <ubizjak@gmail.com>
Thu, 19 Nov 2020 08:23:46 +0000 (09:23 +0100)
committerUros Bizjak <ubizjak@gmail.com>
Thu, 19 Nov 2020 08:25:04 +0000 (09:25 +0100)
This pattern interferes with *<absneg:code><mode>2_1 when TARGET_SSE_MATH
modes are active. Combine pass is able to remove (use) RTXes and transforms
*<absneg:code><mode>2_1 to *<absneg:code><mode>2_i387_1 where SSE
alternatives are not available.

2020-11-19  Uroš Bizjak  <ubizjak@gmail.com>

gcc/
* config/i386/i386.md (*<absneg:code><mode>2_i387_1):
Disable for TARGET_SSE_MATH modes.

gcc/testsuite/
* gcc.target/i386/pr97887.c: New test.

gcc/config/i386/i386.md
gcc/testsuite/gcc.target/i386/pr97887.c [new file with mode: 0644]

index 52e306de00a40185ac79239b955ae5b4be93ac0b..299350147729fb9beaf6aa72a8b16b5153bc3efd 100644 (file)
        (absneg:X87MODEF
          (match_operand:X87MODEF 1 "register_operand" "0,0")))
    (clobber (reg:CC FLAGS_REG))]
-  "TARGET_80387"
+  "TARGET_80387 && !(SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)"
   "#")
 
 (define_split
diff --git a/gcc/testsuite/gcc.target/i386/pr97887.c b/gcc/testsuite/gcc.target/i386/pr97887.c
new file mode 100644 (file)
index 0000000..b457f05
--- /dev/null
@@ -0,0 +1,15 @@
+/* PR target/97887 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -msse2 -mfpmath=sse" } */
+
+float f (float a)
+{
+  return -a / a;
+}
+
+double d (double a)
+{
+  return -a / a;
+}
+
+/* { dg-final { scan-assembler-not "fchs" } } */