public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jeff Law <law@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-1332] [PATCH] PR middle-end/53267: Constant fold BUILT_IN_FMOD. Date: Wed, 9 Jun 2021 15:25:46 +0000 (GMT) [thread overview] Message-ID: <20210609152546.0D5C9398B8A3@sourceware.org> (raw) https://gcc.gnu.org/g:2c17b5f8cca82d1957242055991a2c23184a1af1 commit r12-1332-g2c17b5f8cca82d1957242055991a2c23184a1af1 Author: Roger Sayle <roger@nextmovesoftware.com> Date: Wed Jun 9 11:23:41 2021 -0400 [PATCH] PR middle-end/53267: Constant fold BUILT_IN_FMOD. gcc/ChangeLog PR middle-end/53267 * fold-const-call.c (fold_const_call_sss) [CASE_CFN_FMOD]: Support evaluation of fmod/fmodf/fmodl at compile-time. gcc/testsuite/ChangeLog * gcc.dg/builtins-70.c: New test. Diff: --- gcc/fold-const-call.c | 3 +++ gcc/testsuite/gcc.dg/builtins-70.c | 46 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/gcc/fold-const-call.c b/gcc/fold-const-call.c index a1d70b62c31..d6cb9b11a31 100644 --- a/gcc/fold-const-call.c +++ b/gcc/fold-const-call.c @@ -1375,6 +1375,9 @@ fold_const_call_sss (real_value *result, combined_fn fn, CASE_CFN_FDIM: return do_mpfr_arg2 (result, mpfr_dim, arg0, arg1, format); + CASE_CFN_FMOD: + return do_mpfr_arg2 (result, mpfr_fmod, arg0, arg1, format); + CASE_CFN_HYPOT: return do_mpfr_arg2 (result, mpfr_hypot, arg0, arg1, format); diff --git a/gcc/testsuite/gcc.dg/builtins-70.c b/gcc/testsuite/gcc.dg/builtins-70.c new file mode 100644 index 00000000000..a0c2dc9e9e5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/builtins-70.c @@ -0,0 +1,46 @@ +/* Copyright (C) 2021 Free Software Foundation. + + Check that constant folding of built-in fmod functions doesn't + break anything and produces the expected results. + +/* { dg-do link } */ +/* { dg-options "-O2 -ffast-math" } */ + +extern void link_error(void); + +extern double fmod(double,double); +extern float fmodf(float,float); +extern long double fmodl(long double,long double); + +int main() +{ + if (fmod (6.5, 2.3) < 1.8999 || fmod (6.5, 2.3) > 1.9001) + link_error (); + if (fmod (-6.5, 2.3) < -1.9001 || fmod (-6.5, 2.3) > -1.8999) + link_error (); + if (fmod (6.5, -2.3) < 1.8999 || fmod (6.5, -2.3) > 1.9001) + link_error (); + if (fmod (-6.5, -2.3) < -1.9001 || fmod (-6.5, -2.3) > -1.8999) + link_error (); + + if (fmodf (6.5f, 2.3f) < 1.8999f || fmodf (6.5f, 2.3f) > 1.9001f) + link_error (); + if (fmodf (-6.5f, 2.3f) < -1.9001f || fmodf (-6.5f, 2.3f) > -1.8999f) + link_error (); + if (fmodf (6.5f, -2.3f) < 1.8999f || fmodf (6.5f, -2.3f) > 1.9001f) + link_error (); + if (fmodf (-6.5f, -2.3f) < -1.9001f || fmodf (-6.5f, -2.3f) > -1.8999f) + link_error (); + + if (fmodl (6.5l, 2.3l) < 1.8999l || fmod (6.5l, 2.3l) > 1.9001l) + link_error (); + if (fmodl (-6.5l, 2.3l) < -1.9001l || fmod (-6.5l, 2.3l) > -1.8999l) + link_error (); + if (fmodl (6.5l, -2.3l) < 1.8999l || fmod (6.5l, -2.3l) > 1.9001l) + link_error (); + if (fmodl (-6.5l, -2.3l) < -1.9001l || fmod (-6.5l, -2.3l) > -1.8999l) + link_error (); + + return 0; +} +
reply other threads:[~2021-06-09 15:25 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210609152546.0D5C9398B8A3@sourceware.org \ --to=law@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).