public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/100503] New: A possible divide by zero problem in function do_rpo_vn
@ 2021-05-10 13:59 yguoaz at cse dot ust.hk
  2021-05-10 14:15 ` [Bug tree-optimization/100503] " marxin at gcc dot gnu.org
  2021-05-10 16:25 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: yguoaz at cse dot ust.hk @ 2021-05-10 13:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100503

            Bug ID: 100503
           Summary: A possible divide by zero problem in function
                    do_rpo_vn
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yguoaz at cse dot ust.hk
  Target Milestone: ---

In gcc/tree-ssa-sccvn.c, the function do_rpo_vn has the following code (link to
the code location:
https://github.com/gcc-mirror/gcc/blob/releases/gcc-11/gcc/tree-ssa-sccvn.c#L7815-#L7842)

static unsigned
do_rpo_vn (function *fn, edge entry, bitmap exit_bbs,
           bool iterate, bool eliminate) {
    ...
    int nex = 0;
    ...
    for (int i = 0; i < n; ++i) {
        basic_block bb = BASIC_BLOCK_FOR_FN (fn, rpo[i]);
        if (bb->flags & BB_EXECUTABLE)
            nex++;
    }
    ...
    statistics_histogram_event (cfun, "RPO iterations", 10*nblk / nex);
}

In the loop, the code counts the number of basic blocks with BB_EXECUTABLE flag
in variable nex and use it as divisor after exiting the loop. If no basic block
has such flag, then we will have a divide by zero problem. Is this possible ?
Or we must have at least one bb with the flag BB_EXECUTABLE ?

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-10 16:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-10 13:59 [Bug tree-optimization/100503] New: A possible divide by zero problem in function do_rpo_vn yguoaz at cse dot ust.hk
2021-05-10 14:15 ` [Bug tree-optimization/100503] " marxin at gcc dot gnu.org
2021-05-10 16:25 ` pinskia at gcc dot gnu.org

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).