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

            Bug ID: 93150
           Summary: (A&N) == CST1 &( ((A&M)==CST2) | ((A&O)==CST3) ) is
                    not simplified
           Product: gcc
           Version: 10.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: ---

(x&N) == CST1 & ( ((x&M)==CST2) | ((x&O)==CST3) )
Should be simplified into:
((x&(N|M)) == (CST1|CST2)) | ((x&(N|O)==(CST1|CST3))

Note this can be done for all &/| and ==/!= .
That is:
(for bitop1 (bit_and bit_or)
     bitop2 (bit_or bit_and)
 (for cmp (eq ne)
  (simplify
   (bitop1:c
    (cmp (bit_and @0 INTEGER_CST@N) INTEGER_CST@CST1)
    (bitop2
     (cmp (bit_and @0 INTEGER_CST@N) INTEGER_CST@CST2)
     (cmp (bit_and @0 INTEGER_CST@N) INTEGER_CST@CST3)))
....

Reply via email to