[Bug tree-optimization/114967] Missed optimization: std::min((int) f, -a) ==> -a where (bool f, unsigned char a)

2024-05-07 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114967

--- Comment #3 from Andrew Pinski  ---
I had a patch for this which I didn't finish up and I hope to get it done for
GCC 15.

[Bug tree-optimization/114967] Missed optimization: std::min((int) f, -a) ==> -a where (bool f, unsigned char a)

2024-05-07 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114967

Andrew Pinski  changed:

   What|Removed |Added

   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=107888

--- Comment #2 from Andrew Pinski  ---
We are able to handle this:
```
void func1(bool f, unsigned char a) {
int t = f;
int tt = -a;
int ttt = t <= tt ? t : tt;
n = ttt;
}
```

And we able to handle func if we disable evrp.

So yes the issue is the same as what I mentioned. Basically this is what I
mentioned in bug 107888 comment #2 . But in the original testcase in bug 107888
was able to be handled differently, it is the other testcase that still needs
to be handled.

[Bug tree-optimization/114967] Missed optimization: std::min((int) f, -a) ==> -a where (bool f, unsigned char a)

2024-05-07 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114967

Andrew Pinski  changed:

   What|Removed |Added

   Keywords||missed-optimization
   Last reconfirmed||2024-05-07
 Ever confirmed|0   |1
   Assignee|unassigned at gcc dot gnu.org  |pinskia at gcc dot 
gnu.org
 Status|UNCONFIRMED |ASSIGNED

--- Comment #1 from Andrew Pinski  ---
I think this is a dup of another issue I filed. Where vrp decides to replace
the value in the phi of the max and then it goes down hill from there.

I will take a look.