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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Something like:
(for bitop (bit_and bit_ior)
     cmp   (eq      ne)
 (simplify
  (bitop:c
   (cmp (bit_and @0 INTEGER_CST@mask1) INTEGER_CST@CST1)
   (cmp (bit_and @0 INTEGER_CST@mask2) INTEGER_CST@CST2))
   (with
    {
      tree type1 = TREE_TYPE (@0);
      wide_int mask1 = wi::to_wide (@mask1);
      wide_int mask2 = wi::to_wide (@mask2);
      tree mask = wide_int_to_tree (type1, mask1 | mask2);
    }
    (switch
     (if (bitop == BIT_AND_EXPR
          && operand_equal_p (@mask1, @CST1, OEP_ONLY_CONST)
          && operand_equal_p (@mask1, @CST1, OEP_ONLY_CONST))
      (cmp (bit_and @0 { mask; } ) { mask; } ))
     (if (bitop == BIT_IOR_EXPR
          && integer_onep (@CST1)
          && integer_onep (@CST2))
      (cmp (bit_and @0 { mask; } ) @CST1 )))))

Reply via email to