public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/98117] [8/9/10/11 Regression] wrong code with "-O3 -fno-tree-scev-cprop" since r8-1163-g7078979b291419f3 Date: Mon, 07 Dec 2020 09:27:42 +0000 [thread overview] Message-ID: <bug-98117-4-u2ctd736oz@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-98117-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98117 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |rsandifo at gcc dot gnu.org --- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> --- In fact there is alrady /* Create: niters >> log2(vf) */ /* If it's known that niters == number of latch executions + 1 doesn't overflow, we can generate niters >> log2(vf); otherwise we generate (niters - vf) >> log2(vf) + 1 by using the fact that we know ratio will be at least one. */ so we know about this "defect". The computation method translates easily to the range case (unconditionally). Unfortunately for some 'degenerate' cases where we arrive with const_vf == 1 we'll compute [1, 0] "ranges" this way which ICEs in niter compute. The question is whether we can construct cases we miscompile with such large niter and VF == 1 (full SLP). As noted when I added niter_m1 all uses of 'niter' would have to go away :/ For now I'm testing the "ugly" diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c index 36179188f6d..36f218e7f6e 100644 --- a/gcc/tree-vect-loop-manip.c +++ b/gcc/tree-vect-loop-manip.c @@ -2034,13 +2034,21 @@ vect_gen_vector_loop_niters (loop_vec_info loop_vinfo, tree niters, niters_vector = force_gimple_operand (niters_vector, &stmts, true, var); gsi_insert_seq_on_edge_immediate (pe, stmts); /* Peeling algorithm guarantees that vector loop bound is at least ONE, - we set range information to make niters analyzer's life easier. */ + we set range information to make niters analyzer's life easier. + Note the number of latch iteration value can be TYPE_MAX_VALUE so + we have to represent the vector niter TYPE_MAX_VALUE + 1 >> log_vf. */ if (stmts != NULL && log_vf) set_range_info (niters_vector, VR_RANGE, - wi::to_wide (build_int_cst (type, 1)), - wi::to_wide (fold_build2 (RSHIFT_EXPR, type, - TYPE_MAX_VALUE (type), - log_vf))); + wi::one (TYPE_PRECISION (type)), + /* ??? Avoid creating [1, 0]. */ + const_vf == 1 + ? wi::max_value (TYPE_PRECISION (type), + TYPE_SIGN (type)) + : (wi::rshift (wi::max_value (TYPE_PRECISION (type), + TYPE_SIGN (type)) + - (const_vf - 1), + exact_log2 (const_vf), TYPE_SIGN (type)) + + 1)); } *niters_vector_ptr = niters_vector; *step_vector_ptr = step_vector;
next prev parent reply other threads:[~2020-12-07 9:27 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-12-03 11:31 [Bug tree-optimization/98117] New: wrong code with "-O3 -fno-tree-scev-cprop" suochenyao at 163 dot com 2020-12-03 11:51 ` [Bug tree-optimization/98117] [8/9/10/11 Regression] wrong code with "-O3 -fno-tree-scev-cprop" since r8-1163-g7078979b291419f3 marxin at gcc dot gnu.org 2020-12-03 12:30 ` rguenth at gcc dot gnu.org 2020-12-07 8:39 ` rguenth at gcc dot gnu.org 2020-12-07 8:51 ` rguenth at gcc dot gnu.org 2020-12-07 9:27 ` rguenth at gcc dot gnu.org [this message] 2020-12-07 11:06 ` cvs-commit at gcc dot gnu.org 2020-12-07 11:06 ` [Bug tree-optimization/98117] [8/9/10 " rguenth at gcc dot gnu.org 2021-01-11 14:10 ` cvs-commit at gcc dot gnu.org 2021-03-17 9:35 ` [Bug tree-optimization/98117] [8/9 " cvs-commit at gcc dot gnu.org 2021-04-26 10:46 ` [Bug tree-optimization/98117] [8 " cvs-commit at gcc dot gnu.org 2021-04-26 10:49 ` rguenth at gcc dot gnu.org
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=bug-98117-4-u2ctd736oz@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@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).