This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gomp4] backport the new sincos pattern
- From: Cesar Philippidis <cesar at codesourcery dot com>
- To: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 23 May 2016 07:29:24 -0700
- Subject: [gomp4] backport the new sincos pattern
- Authentication-results: sourceware.org; auth=none
I've committed this patch to backport the new sincos pattern, which is
enabled with -ffast-math, to gomp-4_0-branch.
Cesar
2016-05-23 Cesar Philippidis <cesar@codesourcery.com>
gcc/
* config/nvptx/nvptx.md (sincossf3): New pattern.
gcc/testsuite/
* gcc.target/nvptx/sincos.c: New test.
diff --git a/gcc/config/nvptx/nvptx.md b/gcc/config/nvptx/nvptx.md
index 33a4862..e48412d 100644
--- a/gcc/config/nvptx/nvptx.md
+++ b/gcc/config/nvptx/nvptx.md
@@ -794,6 +794,17 @@
""
"%.\\tsqrt%#%t0\\t%0, %1;")
+(define_expand "sincossf3"
+ [(set (match_operand:SF 0 "nvptx_register_operand" "=R")
+ (unspec:SF [(match_operand:SF 2 "nvptx_register_operand" "R")]
+ UNSPEC_COS))
+ (set (match_operand:SF 1 "nvptx_register_operand" "=R")
+ (unspec:SF [(match_dup 2)] UNSPEC_SIN))]
+ "flag_unsafe_math_optimizations"
+{
+ operands[2] = make_safe_from (operands[2], operands[0]);
+})
+
(define_insn "sinsf2"
[(set (match_operand:SF 0 "nvptx_register_operand" "=R")
(unspec:SF [(match_operand:SF 1 "nvptx_register_operand" "R")]
diff --git a/gcc/testsuite/gcc.target/nvptx/sincos.c b/gcc/testsuite/gcc.target/nvptx/sincos.c
new file mode 100644
index 0000000..921ec41
--- /dev/null
+++ b/gcc/testsuite/gcc.target/nvptx/sincos.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ffast-math" } */
+
+extern float sinf (float);
+extern float cosf (float);
+
+float
+sincos_add (float x)
+{
+ float s = sinf (x);
+ float c = cosf (x);
+
+ return s + c;
+}
+
+/* { dg-final { scan-assembler-times "sin.approx.f32" 1 } } */
+/* { dg-final { scan-assembler-times "cos.approx.f32" 1 } } */