]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/gimple-range-fold.cc
Update copyright years.
[thirdparty/gcc.git] / gcc / gimple-range-fold.cc
index 6e9530c3d7f07fddf3ddda6bd83fe82cdd815008..0cc531999631645528b79675455a41e59db9b17c 100644 (file)
@@ -1,5 +1,5 @@
 /* Code for GIMPLE range related routines.
-   Copyright (C) 2019-2023 Free Software Foundation, Inc.
+   Copyright (C) 2019-2024 Free Software Foundation, Inc.
    Contributed by Andrew MacLeod <amacleod@redhat.com>
    and Aldy Hernandez <aldyh@redhat.com>.
 
@@ -44,6 +44,11 @@ along with GCC; see the file COPYING3.  If not see
 #include "value-query.h"
 #include "gimple-range-op.h"
 #include "gimple-range.h"
+#include "cgraph.h"
+#include "alloc-pool.h"
+#include "symbol-summary.h"
+#include "ipa-utils.h"
+#include "ipa-prop.h"
 // Construct a fur_source, and set the m_query field.
 
 fur_source::fur_source (range_query *q)
@@ -1013,6 +1018,25 @@ fold_using_range::range_of_call (vrange &r, gcall *call, fur_source &)
   else
     r.set_varying (type);
 
+  tree callee = gimple_call_fndecl (call);
+  if (callee
+      && useless_type_conversion_p (TREE_TYPE (TREE_TYPE (callee)), type))
+    {
+      Value_Range val;
+      if (ipa_return_value_range (val, callee))
+       {
+         r.intersect (val);
+         if (dump_file && (dump_flags & TDF_DETAILS))
+           {
+             fprintf (dump_file, "Using return value range of ");
+             print_generic_expr (dump_file, callee, TDF_SLIM);
+             fprintf (dump_file, ": ");
+             val.dump (dump_file);
+             fprintf (dump_file, "\n");
+           }
+       }
+    }
+
   // If there is an LHS, intersect that with what is known.
   if (lhs)
     {