[Bug tree-optimization/96923] Failure to optimize a select-related bool pattern to or+not
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96923 Bug 96923 depends on bug 100864, which changed state. Bug 100864 Summary: (a&!b) | b is not opimized to a | b for comparisons https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100864 What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED
[Bug tree-optimization/96923] Failure to optimize a select-related bool pattern to or+not
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96923 Andrew Pinski changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |DUPLICATE --- Comment #7 from Andrew Pinski --- Ok, this in the end is a dup of bug 89263. *** This bug has been marked as a duplicate of bug 89263 ***
[Bug tree-optimization/96923] Failure to optimize a select-related bool pattern to or+not
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96923 Andrew Pinski changed: What|Removed |Added Depends on||100864 --- Comment #6 from Andrew Pinski --- This depends on PR 100864 if I don't want to write out the 4 patterns. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100864 [Bug 100864] (a&!b) | b is not opimized to a | b for conditionals
[Bug tree-optimization/96923] Failure to optimize a select-related bool pattern to or+not
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96923 --- Comment #5 from Andrew Pinski --- (In reply to Andrew Pinski from comment #4) > Created attachment 50905 [details] > Patch which is in testing (needs testcases) > > As I said for the case in this PR, it needs > https://gcc.gnu.org/pipermail/gcc-patches/2021-June/571616.html too. > > If you change !b to b; that is "!a ? b : 0", this patch will optimize it. > The other patch is needed to allow to move !b out of the conditional. This patch has one bug in it where we need a convert added. BUT then we run into a different missed optimization issue. _51 = p2_22 <= prephitmp_122; _44 = (logical(kind=4)) _51; _37 = p2_22 > prephitmp_122; _49 = (logical(kind=4)) _37; _38 = _49 & found_p_63; _46 = _38 | _44; This is really just: _51 = p2_22 <= prephitmp_122; _44 = (logical(kind=4)) _51; _46 = found_p_63| _44; That is we don't optimize: (a & ~b) | b into a | b if ~b has been converted already. The other thing I noticed is the cast should not be really needed but nothing removes it; I will look at that later. Note I could rewrite the pattern to do the simplification of the constants manually but I want to try to avoid that.
[Bug tree-optimization/96923] Failure to optimize a select-related bool pattern to or+not
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96923 --- Comment #4 from Andrew Pinski --- Created attachment 50905 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50905=edit Patch which is in testing (needs testcases) As I said for the case in this PR, it needs https://gcc.gnu.org/pipermail/gcc-patches/2021-June/571616.html too. If you change !b to b; that is "!a ? b : 0", this patch will optimize it. The other patch is needed to allow to move !b out of the conditional.
[Bug tree-optimization/96923] Failure to optimize a select-related bool pattern to or+not
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96923 Andrew Pinski changed: What|Removed |Added Status|UNCONFIRMED |ASSIGNED Last reconfirmed||2021-06-01 Ever confirmed|0 |1 --- Comment #3 from Andrew Pinski --- Mine, I have a patch which implements this. It needs https://gcc.gnu.org/pipermail/gcc-patches/2021-June/571616.html first. I will be posting this once I write some testcases and do a bootstrap/test cycle.
[Bug tree-optimization/96923] Failure to optimize a select-related bool pattern to or+not
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96923 Andrew Pinski changed: What|Removed |Added Depends on||25290 --- Comment #2 from Andrew Pinski --- Note if we spell out the ?:, this would require PR 25290 too. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25290 [Bug 25290] PHI-OPT could be rewritten so that is uses match
[Bug tree-optimization/96923] Failure to optimize a select-related bool pattern to or+not
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96923 Andrew Pinski changed: What|Removed |Added Severity|normal |enhancement
[Bug tree-optimization/96923] Failure to optimize a select-related bool pattern to or+not
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96923 --- Comment #1 from Gabriel Ravier --- _Bool f2(_Bool a, _Bool b) { return a ? !b : 1; } This similar pattern can be optimized to `return !(a & b);`. This transformation is done by LLVM, but not by GCC.