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

            Bug ID: 114702
           Summary: Missed optimization: fail to infer c - b != if a + b
                    != c
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xxs_chy at outlook dot com
  Target Milestone: ---

Godbolt link: https://godbolt.org/z/58rxGaabW

```
void src(int a, int b){
    if(b + a == 32){
        return;
    }else{
        if(32 - b == a)
            dummy();
        else
            dummy1();
    }
}
```

Obviously, "32 - b == a" is false. We can get:

```
void tgt(int a, int b){
    if(b + a == 32){
        return;
    }else{
        dummy1();
    }
}
```


This is a real-world dead code after inlining functions in QEMU.

Reply via email to