re PR tree-optimization/67741 (Invalid built-in usage should not cause segmentation...
authorRichard Biener <rguenther@suse.de>
Tue, 29 Sep 2015 13:02:42 +0000 (13:02 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 29 Sep 2015 13:02:42 +0000 (13:02 +0000)
2015-09-29  Richard Biener  <rguenther@suse.de>

PR tree-optimization/67741
* tree-ssa-math-opts.c (pass_cse_sincos::execute): Only recognize
builtin calls with correct signature.

* gcc.dg/torture/pr67741.c: New testcase.

From-SVN: r228243

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr67741.c [new file with mode: 0644]
gcc/tree-ssa-math-opts.c

index 12de2e10ae7331f41a8664b8c0220e5522e9834f..8fc37ce595165fa8e2fc0d59fbf6a365a88ea836 100644 (file)
@@ -1,3 +1,9 @@
+2015-09-29  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/67741
+       * tree-ssa-math-opts.c (pass_cse_sincos::execute): Only recognize
+       builtin calls with correct signature.
+
 2015-09-29  Ilya Enkovich  <enkovich.gnu@gmail.com>
 
        PR target/65105
index 09a72d9c9298a4d81d187fc21f80838badb3aea1..6582172b5720bc02dfdf4bab86c8735657bd858c 100644 (file)
@@ -1,3 +1,8 @@
+2015-09-29  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/67741
+       * gcc.dg/torture/pr67741.c: New testcase.
+
 2015-09-29  Uros Bizjak  <ubizjak@gmail.com>
 
        * gcc.dg/tg-tests.h (foo_1) [UNSAFE]: Also check if f and ld are
diff --git a/gcc/testsuite/gcc.dg/torture/pr67741.c b/gcc/testsuite/gcc.dg/torture/pr67741.c
new file mode 100644 (file)
index 0000000..1ffc707
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+struct singlecomplex { float real, imag ; } ;
+struct doublecomplex { double real, imag ; } ;
+struct extendedcomplex { long double real, imag ; } ;
+extern double cabs();
+float cabsf(fc)
+     struct singlecomplex fc;  /* { dg-warning "doesn't match" } */
+{
+  struct doublecomplex dc ;
+  dc.real=fc.real; dc.imag=fc.imag;
+  return (float) cabs(dc);
+}
index 42708ee6ad1b711be0d72f570224628645bb8ec2..97477391e0f47fc1f700bfc0eb10cc4c90cdd6af 100644 (file)
@@ -1738,15 +1738,14 @@ pass_cse_sincos::execute (function *fun)
             of a basic block.  */
          cleanup_eh = false;
 
-         if (is_gimple_call (stmt)
-             && gimple_call_lhs (stmt)
-             && (fndecl = gimple_call_fndecl (stmt))
-             && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
+         if (gimple_call_builtin_p (stmt, BUILT_IN_NORMAL)
+             && gimple_call_lhs (stmt))
            {
              tree arg, arg0, arg1, result;
              HOST_WIDE_INT n;
              location_t loc;
 
+             fndecl = gimple_call_fndecl (stmt);
              switch (DECL_FUNCTION_CODE (fndecl))
                {
                CASE_FLT_FN (BUILT_IN_COS):