From: Uros Bizjak Date: Sun, 16 Feb 2020 20:38:39 +0000 (+0100) Subject: i386: Fix atan2l argument order [PR93743] X-Git-Tag: basepoints/gcc-11~1416 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6e37e49616d429c5d922324ebd72ae95f12a079f;p=thirdparty%2Fgcc.git i386: Fix atan2l argument order [PR93743] PR target/93743 * config/i386/i386.md (atan2xf3): Swap operands 1 and 2. (atan23): Update operand order in the call to gen_atan2xf3. testsuite/ChangeLog: PR target/93743 * gcc.target/i386/pr93743.c : New test. --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6283e8087b78..c7a551b48963 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2020-02-16 Uroš Bizjak + + PR target/93743 + * config/i386/i386.md (atan2xf3): Swap operands 1 and 2. + (atan23): Update operand order in the call to gen_atan2xf3. + 2020-02-15 Jason Merrill * 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 f14683cd14fa..6c57500ae8ec 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_extendxf2 (op2, operands[2])); emit_insn (gen_extendxf2 (op1, operands[1])); - emit_insn (gen_atan2xf3 (op0, op2, op1)); + emit_insn (gen_atan2xf3 (op0, op1, op2)); emit_insn (gen_truncxf2 (operands[0], op0)); DONE; }) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7c198dcdc693..f2566ad9844f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-02-16 Uroš Bizjak + + PR target/93743 + * gcc.target/i386/pr93743.c : New test. + 2020-02-15 Marek Polacek 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 000000000000..c0e9d2c3e2c4 --- /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; +}