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

            Bug ID: 120003
           Summary: Missed Optimisation / Regression
           Product: gcc
           Version: 15.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: phdiv at fastmail dot fm
  Target Milestone: ---

Consider the following code:

  extern bool g(int);

  bool f(){
    bool retval = false;
    for(int i=0; i<1'000'000; ++i)
        retval = retval || g(i);
    return retval;
  }

Up until GCC 11, it was recognised that the loop can be exited as soon
as the first call to  g  returns true. Since GCC 12, and present up to 15,
the loop keeps on incrementing needlessly.

https://godbolt.org/z/q5qKbcoMG

Reply via email to