public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed][GCC-10 backport] d: Explicitly determine which built-in copysign function to call.
@ 2020-11-18 10:33 Iain Buclaw
  0 siblings, 0 replies; only message in thread
From: Iain Buclaw @ 2020-11-18 10:33 UTC (permalink / raw)
  To: gcc-patches

Hi,

This patch backports r11-4980 to GCC-10, as it fixes an ICE that could
occur on some targets.

Regression tested on x86_64-linux-gnu and committed to branch.

Regards
Iain

---
gcc/d/ChangeLog:

	* intrinsics.cc (expand_intrinsic_copysign): Explicitly determine
	which built-in copysign function to call.

(cherry picked from commit d975d6dce98a3e26ddd304d50dad2786b3acecc4)
---
 gcc/d/intrinsics.cc | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/gcc/d/intrinsics.cc b/gcc/d/intrinsics.cc
index c32819885bb..51cbd7b92fd 100644
--- a/gcc/d/intrinsics.cc
+++ b/gcc/d/intrinsics.cc
@@ -430,11 +430,14 @@ expand_intrinsic_copysign (tree callexp)
     from = fold_convert (type, from);
 
   /* Which variant of __builtin_copysign* should we call?  */
-  tree builtin = mathfn_built_in (type, BUILT_IN_COPYSIGN);
-  gcc_assert (builtin != NULL_TREE);
+  built_in_function code = (type == float_type_node) ? BUILT_IN_COPYSIGNF
+    : (type == double_type_node) ? BUILT_IN_COPYSIGN
+    : (type == long_double_type_node) ? BUILT_IN_COPYSIGNL
+    : END_BUILTINS;
 
-  return call_builtin_fn (callexp, DECL_FUNCTION_CODE (builtin), 2,
-			  to, from);
+  gcc_assert (code != END_BUILTINS);
+
+  return call_builtin_fn (callexp, code, 2, to, from);
 }
 
 /* Expand a front-end intrinsic call to pow().  This takes two arguments, the
-- 
2.27.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-11-18 10:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-18 10:33 [committed][GCC-10 backport] d: Explicitly determine which built-in copysign function to call Iain Buclaw

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).