[Bug tree-optimization/94898] Failure to optimize compare plus sub of same operands into compare
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94898 Bug 94898 depends on bug 89263, which changed state. Bug 89263 Summary: Simplify bool expression to OR https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89263 What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED
[Bug tree-optimization/94898] Failure to optimize compare plus sub of same operands into compare
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94898 Andrew Pinski changed: What|Removed |Added Target Milestone|--- |14.0 Status|ASSIGNED|RESOLVED Resolution|--- |FIXED --- Comment #7 from Andrew Pinski --- Fixed.
[Bug tree-optimization/94898] Failure to optimize compare plus sub of same operands into compare
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94898 --- Comment #6 from CVS Commits --- The trunk branch has been updated by Andrew Pinski : https://gcc.gnu.org/g:64d90d06d2db43538c8a45adbb3d74842f7868ae commit r14-1597-g64d90d06d2db43538c8a45adbb3d74842f7868ae Author: Andrew Pinski Date: Wed May 24 07:08:45 2023 + Add match patterns for `a ? onezero : onezero` where one of the two operands are constant This adds a match pattern that are for boolean values that optimizes `a ? onezero : 0` to `a & onezero` and `a ? 1 : onezero` to `a | onezero`. This was reported a few times and I thought I would finally add the match pattern for this. This hits a few times in GCC itself too. Notes on the testcases: * phi-opt-2.c: This now is optimized to `a & b` in phiopt rather than ifcombine * phi-opt-25b.c: The test part that was failing was parity which now gets `x & y` treatment. * ssa-thread-21.c: there is no longer a threading opportunity, so need to disable phiopt. Note PR 109957 is filed for the now missing optimization in that testcase too. gcc/ChangeLog: PR tree-optimization/89263 PR tree-optimization/99069 PR tree-optimization/20083 PR tree-optimization/94898 * match.pd: Add patterns to optimize `a ? onezero : onezero` with one of the operands are constant. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/phi-opt-2.c: Adjust the testcase. * gcc.dg/tree-ssa/phi-opt-25b.c: Adjust the testcase. * gcc.dg/tree-ssa/ssa-thread-21.c: Disable phiopt. * gcc.dg/tree-ssa/phi-opt-27.c: New test. * gcc.dg/tree-ssa/phi-opt-28.c: New test. * gcc.dg/tree-ssa/phi-opt-29.c: New test. * gcc.dg/tree-ssa/phi-opt-30.c: New test. * gcc.dg/tree-ssa/phi-opt-31.c: New test. * gcc.dg/tree-ssa/phi-opt-32.c: New test.
[Bug tree-optimization/94898] Failure to optimize compare plus sub of same operands into compare
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94898 --- Comment #5 from Andrew Pinski --- Patch submitted: https://gcc.gnu.org/pipermail/gcc-patches/2023-June/620829.html
[Bug tree-optimization/94898] Failure to optimize compare plus sub of same operands into compare
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94898 Andrew Pinski changed: What|Removed |Added Depends on||89263 --- Comment #4 from Andrew Pinski --- The patch which fixes this is the same as PR 89263 . Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89263 [Bug 89263] Simplify bool expression to OR
[Bug tree-optimization/94898] Failure to optimize compare plus sub of same operands into compare
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94898 Bug 94898 depends on bug 96923, which changed state. Bug 96923 Summary: Failure to optimize a select-related bool pattern to or+not https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96923 What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |DUPLICATE
[Bug tree-optimization/94898] Failure to optimize compare plus sub of same operands into compare
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94898 --- Comment #3 from Andrew Pinski --- The other transformation of "x_2 >= y_3 && x_2 != y_3" into "x_2 > y_3" is already done by reassociation and has been done since 4.5.0.
[Bug tree-optimization/94898] Failure to optimize compare plus sub of same operands into compare
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94898 Andrew Pinski changed: What|Removed |Added Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot gnu.org Ever confirmed|0 |1 Last reconfirmed||2022-02-21 Status|UNCONFIRMED |ASSIGNED --- Comment #2 from Andrew Pinski --- We have: if (x_2(D) >= y_3(D)) goto ; [34.00%] else goto ; [66.00%] [local count: 365072224]: _4 = x_2(D) != y_3(D); [local count: 1073741824]: # _1 = PHI <_4(3), 0(2)> Which is: x_2 >= y_3 ? x_2 != y_3 : 0 which can be optimized to: x_2 >= y_3 && x_2 != y_3 Which then simplifies to just: x_2 > y_3 I have a few patches to do the first transformation which should be ready for GCC 13.
[Bug tree-optimization/94898] Failure to optimize compare plus sub of same operands into compare
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94898 Andrew Pinski changed: What|Removed |Added Severity|normal |enhancement
[Bug tree-optimization/94898] Failure to optimize compare plus sub of same operands into compare
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94898 --- Comment #1 from Gabriel Ravier --- Also, if this function is changed to return `int`, it can then be optimized to a conditional move, which GCC fails to do