public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Aldy Hernandez <aldyh@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-3762] PR97359: Do not cache relops in GORI cache. Date: Sat, 10 Oct 2020 08:26:50 +0000 (GMT) [thread overview] Message-ID: <20201010082650.717C83857C52@sourceware.org> (raw) https://gcc.gnu.org/g:14db1dfcd18e4d2712a043bdcd3976fcfb0642c2 commit r11-3762-g14db1dfcd18e4d2712a043bdcd3976fcfb0642c2 Author: Aldy Hernandez <aldyh@redhat.com> Date: Sat Oct 10 08:28:52 2020 +0200 PR97359: Do not cache relops in GORI cache. logical_stmt_cache::cacheable_p() returns true for relops, but logical_combine (which does the caching) doesn't handle them and ICEs. This patch fixes the inconsistency by returning false for relops. This was working before because even though logical_combine doesn't handle relops, statements with only one SSA are handled in cache_stmt, which seems like the only statement we've ever encountered (even through a full Fedora build). lhs = s_5 > 999; However, with two SSA operands we ICE because logical_combine doesn't handle them: lhs = s_5 > y_8; We can either return false for relops in cacheable_p, or fix logical_combine to handle them. The original idea was to only cache ANDs and ORs, so I've done the former to unbreak trunk. We can decide later if there was ever any benefit in caching relops. gcc/ChangeLog: PR tree-optimization/97359 * gimple-range-gori.cc (logical_stmt_cache::cacheable_p): Only handle ANDs and ORs. (gori_compute_cache::cache_stmt): Adjust comment. gcc/testsuite/ChangeLog: * gcc.dg/pr97359.c: New test. Diff: --- gcc/gimple-range-gori.cc | 10 ++-------- gcc/testsuite/gcc.dg/pr97359.c | 11 +++++++++++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/gcc/gimple-range-gori.cc b/gcc/gimple-range-gori.cc index eaf1a445c25..986427669a7 100644 --- a/gcc/gimple-range-gori.cc +++ b/gcc/gimple-range-gori.cc @@ -1161,12 +1161,6 @@ logical_stmt_cache::cacheable_p (gimple *stmt, const irange *lhs_range) const { switch (gimple_expr_code (stmt)) { - case LT_EXPR: - case LE_EXPR: - case GT_EXPR: - case GE_EXPR: - case EQ_EXPR: - case NE_EXPR: case TRUTH_AND_EXPR: case BIT_AND_EXPR: case TRUTH_OR_EXPR: @@ -1294,7 +1288,7 @@ gori_compute_cache::cache_stmt (gimple *stmt) tree op2 = gimple_range_operand2 (stmt); int_range_max r_true_side, r_false_side; - // LHS = s_5 > 999. + // LHS = s_5 && 999. if (TREE_CODE (op2) == INTEGER_CST) { range_operator *handler = range_op_handler (code, TREE_TYPE (lhs)); @@ -1305,7 +1299,7 @@ gori_compute_cache::cache_stmt (gimple *stmt) handler->op1_range (r_false_side, type, m_bool_zero, op2_range); m_cache->set_range (lhs, op1, tf_range (r_true_side, r_false_side)); } - // LHS = s_5 > b_8. + // LHS = s_5 && b_8. else if (tree cached_name = m_cache->same_cached_name (op1, op2)) { tf_range op1_range, op2_range; diff --git a/gcc/testsuite/gcc.dg/pr97359.c b/gcc/testsuite/gcc.dg/pr97359.c new file mode 100644 index 00000000000..142542e404c --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr97359.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -w" } */ + +typedef unsigned int uint32_t; +int a; +void b(uint32_t c) { + uint32_t *d = &c; + for (; a;) + for (;; (*d %= a) / (*d > 1 > (c > 0)) ?: d) + ; +}
reply other threads:[~2020-10-10 8:26 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=20201010082650.717C83857C52@sourceware.org \ --to=aldyh@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).