[gcc(refs/vendors/ibm/heads/perf)] i386: Fix atan2l argument order [PR93743]

Jiu Fu Guo guojiufu@gcc.gnu.org
Thu Mar 19 05:36:17 GMT 2020


https://gcc.gnu.org/g:6e37e49616d429c5d922324ebd72ae95f12a079f

commit 6e37e49616d429c5d922324ebd72ae95f12a079f
Author: Uros Bizjak <ubizjak@gmail.com>
Date:   Sun Feb 16 21:38:39 2020 +0100

    i386: Fix atan2l argument order [PR93743]
    
            PR target/93743
            * config/i386/i386.md (atan2xf3): Swap operands 1 and 2.
            (atan2<mode>3): Update operand order in the call to gen_atan2xf3.
    
    testsuite/ChangeLog:
    
            PR target/93743
            * gcc.target/i386/pr93743.c : New test.

Diff:
---
 gcc/ChangeLog                           |  6 ++++++
 gcc/config/i386/i386.md                 |  8 ++++----
 gcc/testsuite/ChangeLog                 |  5 +++++
 gcc/testsuite/gcc.target/i386/pr93743.c | 30 ++++++++++++++++++++++++++++++
 4 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6283e8087b7..c7a551b4896 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2020-02-16  Uroš Bizjak  <ubizjak@gmail.com>
+
+	PR target/93743
+	* config/i386/i386.md (atan2xf3): Swap operands 1 and 2.
+	(atan2<mode>3): Update operand order in the call to gen_atan2xf3.
+
 2020-02-15  Jason Merrill  <jason@redhat.com>
 
 	* doc/invoke.texi (C Dialect Options): Add -std=c++20.
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index f14683cd14f..6c57500ae8e 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -15999,10 +15999,10 @@
 
 (define_insn "atan2xf3"
   [(set (match_operand:XF 0 "register_operand" "=f")
-        (unspec:XF [(match_operand:XF 1 "register_operand" "0")
-	            (match_operand:XF 2 "register_operand" "f")]
+        (unspec:XF [(match_operand:XF 2 "register_operand" "0")
+	            (match_operand:XF 1 "register_operand" "f")]
 	           UNSPEC_FPATAN))
-   (clobber (match_scratch:XF 3 "=2"))]
+   (clobber (match_scratch:XF 3 "=1"))]
   "TARGET_USE_FANCY_MATH_387
    && flag_unsafe_math_optimizations"
   "fpatan"
@@ -16026,7 +16026,7 @@
   emit_insn (gen_extend<mode>xf2 (op2, operands[2]));
   emit_insn (gen_extend<mode>xf2 (op1, operands[1]));
 
-  emit_insn (gen_atan2xf3 (op0, op2, op1));
+  emit_insn (gen_atan2xf3 (op0, op1, op2));
   emit_insn (gen_truncxf<mode>2 (operands[0], op0));
   DONE;
 })
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 7c198dcdc69..f2566ad9844 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2020-02-16  Uroš Bizjak  <ubizjak@gmail.com>
+
+	PR target/93743
+	* gcc.target/i386/pr93743.c : New test.
+
 2020-02-15  Marek Polacek  <polacek@redhat.com>
 
 	PR c++/93710 - poor diagnostic for array initializer.
diff --git a/gcc/testsuite/gcc.target/i386/pr93743.c b/gcc/testsuite/gcc.target/i386/pr93743.c
new file mode 100644
index 00000000000..c0e9d2c3e2c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr93743.c
@@ -0,0 +1,30 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -ffast-math -mfpmath=387" } */
+
+void
+__attribute__((noinline))
+test (long double x, long double y)
+{
+  long double ldbl_n = __builtin_atan2l (x, y);
+  long double ldbl_s = __builtin_atan2l (y, x);  // arguments swapped
+
+  if (ldbl_n < 1.L ||  1.L < ldbl_s)
+    __builtin_abort ();
+
+  double dbl_n = __builtin_atan2  (x, y);
+  double dbl_s = __builtin_atan2  (y, x);  // arguments swapped
+
+  if (dbl_n < 1. ||  1. < dbl_s)
+    __builtin_abort ();
+}
+
+int
+main ()
+{
+  long double x = 0.922766L;
+  long double y = 0.080466L;
+
+  test (x, y);
+
+  return 0;
+}


More information about the Gcc-cvs mailing list