[Bug tree-optimization/101650] New: (len | N) == len is transformed to len & N != 0

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jul 27 19:55:47 GMT 2021


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

            Bug ID: 101650
           Summary: (len | N) == len is transformed to len & N != 0
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

While looking at PR 101590, I noticed this one.
#include <stddef.h>

const size_t N = 4;

bool foo(size_t len) {
        size_t newlen = len | N;
        return newlen == len;
}


(for cmp  (NE EQ)
     icmp (EQ NE)
 (simplify
  (cmp (bit_ior @0 INTEGER_CST@1) @0)
  (icmp (bit_and @0 @1) ({ build_zero_cst (TREE_TYPE (@0)); })
 )
)

This is already done for bit_and.


More information about the Gcc-bugs mailing list