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

            Bug ID: 122805
           Summary: bbro pass unexpected bb duplication
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wg14 at ascz dot de
  Target Milestone: ---

https://godbolt.org/z/MTEK963Mc

Compiling the following code with -O2

void foo();
void bar();

void foobar(unsigned int a) {
    unsigned int i = 0;
    if(a){
        while(i<1000){
                foo();
                i++;
        }
    }else{
        while(i<1000){
            bar();
            i++;
        }
    }
}

the basic block of the else branch is duplicated by the bbro pass. This is
unexpected, as the same isn't done for the following code

void barfoo(unsigned int a) {
    unsigned int i = 0;
    if(a){
        while(i<1000){
                foo();
                i++;
        }
    }else{
        while(i<10000){ // more iterations
            bar();
            i++;
        }
    }
}

Reply via email to