public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Andrew Pinski <pinskia@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-1832] Fix PR 101230: ICE in fold_cond_expr_with_comparison Date: Sun, 27 Jun 2021 23:14:58 +0000 (GMT) [thread overview] Message-ID: <20210627231458.F03F2383800B@sourceware.org> (raw) https://gcc.gnu.org/g:37ad257c06d88fdb810be336d212c1ab54b99dad commit r12-1832-g37ad257c06d88fdb810be336d212c1ab54b99dad Author: Andrew Pinski <apinski@marvell.com> Date: Sun Jun 27 13:14:48 2021 -0700 Fix PR 101230: ICE in fold_cond_expr_with_comparison This fixes PR 101230 where I had messed up and forgot that invert_tree_comparison can return ERROR_MARK if the comparsion is not invertable (floating point types). Committed as obvious after a bootstrap/test on x86_64-linux-gnu-gnu gcc/ChangeLog: PR middle-end/101230 * fold-const.c (fold_ternary_loc): Check the return value of invert_tree_comparison. gcc/testsuite/ChangeLog: * gcc.dg/torture/pr101230-1.c: New test. Diff: --- gcc/fold-const.c | 9 +++++---- gcc/testsuite/gcc.dg/torture/pr101230-1.c | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/gcc/fold-const.c b/gcc/fold-const.c index e2110b6bffe..dfccbaec683 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -12837,10 +12837,11 @@ fold_ternary_loc (location_t loc, enum tree_code code, tree type, tree arg00 = TREE_OPERAND (arg0, 0); tree arg01 = TREE_OPERAND (arg0, 1); comp_code = invert_tree_comparison (comp_code, HONOR_NANS (arg00)); - tem = fold_cond_expr_with_comparison (loc, type, comp_code, - arg00, - arg01, - op2, op1); + if (comp_code != ERROR_MARK) + tem = fold_cond_expr_with_comparison (loc, type, comp_code, + arg00, + arg01, + op2, op1); if (tem) return tem; } diff --git a/gcc/testsuite/gcc.dg/torture/pr101230-1.c b/gcc/testsuite/gcc.dg/torture/pr101230-1.c new file mode 100644 index 00000000000..f10ca8b1f49 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr101230-1.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fno-signed-zeros" } */ + + +double distance3d_sqr_pt4d_pt4d(void); + +int update_r_k_curr_cluster; +void update_r_k(void) { + double curr_distance = distance3d_sqr_pt4d_pt4d(); + for (int cluster; cluster; cluster++) + if (0 < curr_distance) { + curr_distance = 0; + update_r_k_curr_cluster = cluster; + } +}
reply other threads:[~2021-06-27 23:14 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=20210627231458.F03F2383800B@sourceware.org \ --to=pinskia@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).