public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/53979] New: (a^b^b) not simplified to (a)   (in combination with CSE??)
@ 2012-07-16 10:41 vermaelen.wouter at gmail dot com
  2020-06-03  3:18 ` [Bug tree-optimization/53979] ((a ^ b) | a) not optimized to (a | b) gabravier at gmail dot com
  2021-07-28 22:19 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: vermaelen.wouter at gmail dot com @ 2012-07-16 10:41 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53979

             Bug #: 53979
           Summary: (a^b^b) not simplified to (a)   (in combination with
                    CSE??)
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: vermaelen.wouter@gmail.com


The following 3 functions should ideally generate identical code (and they do
when using clang).

int f1(int a, int b) {
    int c = b;
    return (a ^ b ^ c) | (a ^ b) | a;
}
int f2(int a, int b) {
    return (a ^ b) | a;
}
int f3(int a, int b) {
    return a | b;
}

I tested gcc revision trunk@189510 and it shows 2 missed optimizations:

1) (a ^ b ^ b) not simplified to (a)
Normally gcc performs this optimization, but I *guess* it misses it here
because of the CSE opportunity with (a ^ b).

2) ((a ^ b) | a) not simplified to (a | b)


Of course in this example it's easy to manually rewrite the code. But in my
original code this function was actually a template and for some instantiations
the expression for the variable 'c' simplified to just 'b'. So the first missed
optimization is something I saw in real code. The second missed optimization
only occurs in this (much) simplified variant of the function.


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

* [Bug tree-optimization/53979] ((a ^ b) | a) not optimized to (a | b)
  2012-07-16 10:41 [Bug tree-optimization/53979] New: (a^b^b) not simplified to (a) (in combination with CSE??) vermaelen.wouter at gmail dot com
@ 2020-06-03  3:18 ` gabravier at gmail dot com
  2021-07-28 22:19 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: gabravier at gmail dot com @ 2020-06-03  3:18 UTC (permalink / raw)
  To: gcc-bugs

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

Gabriel Ravier <gabravier at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gabravier at gmail dot com

--- Comment #4 from Gabriel Ravier <gabravier at gmail dot com> ---
I've just checked on trunk and it looks fixed

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

* [Bug tree-optimization/53979] ((a ^ b) | a) not optimized to (a | b)
  2012-07-16 10:41 [Bug tree-optimization/53979] New: (a^b^b) not simplified to (a) (in combination with CSE??) vermaelen.wouter at gmail dot com
  2020-06-03  3:18 ` [Bug tree-optimization/53979] ((a ^ b) | a) not optimized to (a | b) gabravier at gmail dot com
@ 2021-07-28 22:19 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-28 22:19 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |7.0
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed for GCC 7.

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

end of thread, other threads:[~2021-07-28 22:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-16 10:41 [Bug tree-optimization/53979] New: (a^b^b) not simplified to (a) (in combination with CSE??) vermaelen.wouter at gmail dot com
2020-06-03  3:18 ` [Bug tree-optimization/53979] ((a ^ b) | a) not optimized to (a | b) gabravier at gmail dot com
2021-07-28 22:19 ` pinskia at gcc dot gnu.org

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).