public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/93150] (A&N) == CST1 &( ((A&M)==CST2) | ((A&O)==CST3) ) is not simplified
       [not found] <bug-93150-4@http.gcc.gnu.org/bugzilla/>
@ 2021-11-10 18:00 ` navidrahimi at microsoft dot com
  2021-11-11 18:59 ` david.bolvansky at gmail dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 4+ messages in thread
From: navidrahimi at microsoft dot com @ 2021-11-10 18:00 UTC (permalink / raw)
  To: gcc-bugs

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

navidrahimi <navidrahimi at microsoft dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |navidrahimi at microsoft dot com

--- Comment #1 from navidrahimi <navidrahimi at microsoft dot com> ---
I was just checking this bug and I don't see how this can be a win though: 

Expression: (x&N) == CST1 & ( ((x&M)==CST2) | ((x&O)==CST3))
Number of operations: 
&:4
|:1
==:3

Expression: ((x&(N|M)) == (CST1|CST2)) | ((x&(N|O)==(CST1|CST3))
Number of operations: 
&:2
|:5
==:2

P.S. I might be missing something here though.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug tree-optimization/93150] (A&N) == CST1 &( ((A&M)==CST2) | ((A&O)==CST3) ) is not simplified
       [not found] <bug-93150-4@http.gcc.gnu.org/bugzilla/>
  2021-11-10 18:00 ` [Bug tree-optimization/93150] (A&N) == CST1 &( ((A&M)==CST2) | ((A&O)==CST3) ) is not simplified navidrahimi at microsoft dot com
@ 2021-11-11 18:59 ` david.bolvansky at gmail dot com
  2021-11-11 19:01 ` navidrahimi at microsoft dot com
  2021-11-11 20:41 ` navidrahimi at microsoft dot com
  3 siblings, 0 replies; 4+ messages in thread
From: david.bolvansky at gmail dot com @ 2021-11-11 18:59 UTC (permalink / raw)
  To: gcc-bugs

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

Dávid Bolvanský <david.bolvansky at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |david.bolvansky at gmail dot com

--- Comment #2 from Dávid Bolvanský <david.bolvansky at gmail dot com> ---
Bin ops with constants are simplified by compiler itself..

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug tree-optimization/93150] (A&N) == CST1 &( ((A&M)==CST2) | ((A&O)==CST3) ) is not simplified
       [not found] <bug-93150-4@http.gcc.gnu.org/bugzilla/>
  2021-11-10 18:00 ` [Bug tree-optimization/93150] (A&N) == CST1 &( ((A&M)==CST2) | ((A&O)==CST3) ) is not simplified navidrahimi at microsoft dot com
  2021-11-11 18:59 ` david.bolvansky at gmail dot com
@ 2021-11-11 19:01 ` navidrahimi at microsoft dot com
  2021-11-11 20:41 ` navidrahimi at microsoft dot com
  3 siblings, 0 replies; 4+ messages in thread
From: navidrahimi at microsoft dot com @ 2021-11-11 19:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Navid Rahimi <navidrahimi at microsoft dot com> ---
Thanks Dávid, that does make sense. I forgot about constant elimination. I will
send a patch for this.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug tree-optimization/93150] (A&N) == CST1 &( ((A&M)==CST2) | ((A&O)==CST3) ) is not simplified
       [not found] <bug-93150-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2021-11-11 19:01 ` navidrahimi at microsoft dot com
@ 2021-11-11 20:41 ` navidrahimi at microsoft dot com
  3 siblings, 0 replies; 4+ messages in thread
From: navidrahimi at microsoft dot com @ 2021-11-11 20:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Navid Rahimi <navidrahimi at microsoft dot com> ---
Although I wrote a small code to just test this optimization. But I am not able
to verify this transformation [1].

https://alive2.llvm.org/ce/z/THP27D

The code can be something like this but if I were able to verify the
optimization, I don't see any reason why N, M, O should be constant too. 




/* ((x & N) == CST1) bitop1 (((x & M) == CST2) bitop2 ((x & O) == CST3)) -> ((x
& (N | M)) == (CST1 | CST2)) bitopt2 ((x & (N | O)) == (CST1 | CST3)) */
(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)))
    (bitop2:c
      (cmp (bit_and:c @0 (bit_or INTEGER_CST@N INTEGER_CST@M)) (bit_or
INTEGER_CST@CST1 INTEGER_CST@CST2))
      (cmp (bit_and:c @0 (bit_or INTEGER_CST@N INTEGER_CST@O)) (bit_or
INTEGER_CST@CST1 INTEGER_CST@CST3))))))

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-11-11 20:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-93150-4@http.gcc.gnu.org/bugzilla/>
2021-11-10 18:00 ` [Bug tree-optimization/93150] (A&N) == CST1 &( ((A&M)==CST2) | ((A&O)==CST3) ) is not simplified navidrahimi at microsoft dot com
2021-11-11 18:59 ` david.bolvansky at gmail dot com
2021-11-11 19:01 ` navidrahimi at microsoft dot com
2021-11-11 20:41 ` navidrahimi at microsoft dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).