nvptx.md (sincossf3): New pattern.
authorCesar Philippidis <cesar@codesourcery.com>
Fri, 20 May 2016 17:33:44 +0000 (10:33 -0700)
committerCesar Philippidis <cesar@gcc.gnu.org>
Fri, 20 May 2016 17:33:44 +0000 (10:33 -0700)
gcc/
* config/nvptx/nvptx.md (sincossf3): New pattern.

gcc/testsuite/
* gcc.target/nvptx/sincos.c: New test.

From-SVN: r236523

gcc/ChangeLog
gcc/config/nvptx/nvptx.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/nvptx/sincos.c [new file with mode: 0644]

index 0a5526dd1aee32c906d4ed349bdca4d23a2e3611..69d61eefc9d51681ae09f89c31e9ad355bbc2094 100644 (file)
@@ -1,3 +1,7 @@
+2016-05-20  Cesar Philippidis  <cesar@codesourcery.com>
+
+       * config/nvptx/nvptx.md (sincossf3): New pattern.
+
 2016-05-20  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR target/70738
index 33a4862b98e15def25b63ee6c457267fda1cee93..e48412de6a6f6b299f65a63f968c5e988a6d374e 100644 (file)
   ""
   "%.\\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")]
index cb9363b9a88ab55b623f41e56d77620461ce93d0..919c1241f3a0e63796909bd2ab0ccd14ab7a0d04 100644 (file)
@@ -1,3 +1,7 @@
+2016-05-20  Cesar Philippidis  <cesar@codesourcery.com>
+
+       * gcc.target/nvptx/sincos.c: New test.
+
 2016-05-20  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/70572
diff --git a/gcc/testsuite/gcc.target/nvptx/sincos.c b/gcc/testsuite/gcc.target/nvptx/sincos.c
new file mode 100644 (file)
index 0000000..921ec41
--- /dev/null
@@ -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 } } */