On Tue, Nov 30, 2021 at 8:35 AM Navid Rahimi via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > Hi GCC community, > > This patch will add the missed pattern described in bug 98956 [1] to the > match.pd. The codegen and correctness proof for this pattern is here [2,3] in > case anyone is curious. Tested on x86_64 Linux. >
A better way to optimize this is the following (which I describe in PR 64992): take: (t << 1) != 0; This should be transformed into: (t & 0x7fffffff) != 0 The rest will just fall out really. That is there is no reason to special case bool here. I have most of the patch except for creating the mask part which should be simple, I just did not want to look up the wi:: functions at the time I was writing it into the bug report. Thanks, Andrew Pinski > Tree-optimization/98956: > > Adding new optimization to match.pd: > * match.pd ((B0 << x) cmp 0) -> B0 cmp 0 : New optimization. > * gcc.dg/tree-ssa/pr98956.c: testcase for this optimization. > * gcc.dg/tree-ssa/pr98956-2.c: testcase for node with > side-effect. > > 1) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98956 > 2) https://compiler-explorer.com/z/nj4PTrecW > 3) https://alive2.llvm.org/ce/z/jyJAoS > > Best wishes, > Navid.