public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/114702] New: Missed optimization: fail to infer c - b != if a + b != c
@ 2024-04-12 13:50 xxs_chy at outlook dot com
  2024-04-12 22:33 ` [Bug tree-optimization/114702] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: xxs_chy at outlook dot com @ 2024-04-12 13:50 UTC (permalink / raw)
  To: gcc-bugs

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.

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

* [Bug tree-optimization/114702] Missed optimization: fail to infer c - b != if a + b != c
  2024-04-12 13:50 [Bug tree-optimization/114702] New: Missed optimization: fail to infer c - b != if a + b != c xxs_chy at outlook dot com
@ 2024-04-12 22:33 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-12 22:33 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2024-04-12
           Severity|normal                      |enhancement
             Status|UNCONFIRMED                 |NEW
             Blocks|                            |85316

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed. 

VRP does some of this but I am not sure if it can be expanded to be handle more
general value relations here


Folding statement: if (_2 == a_5(D))
 Registering value_relation (_2 == a_5(D)) on (3->4)
 Registering value_relation (_2 != a_5(D)) on (3->5)


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85316
[Bug 85316] [meta-bug] VRP range propagation missed cases

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

end of thread, other threads:[~2024-04-12 22:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-12 13:50 [Bug tree-optimization/114702] New: Missed optimization: fail to infer c - b != if a + b != c xxs_chy at outlook dot com
2024-04-12 22:33 ` [Bug tree-optimization/114702] " 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).