public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/52345] New: Missed optimization dealing with bools
@ 2012-02-22 21:45 pinskia at gcc dot gnu.org
  2012-02-22 22:05 ` [Bug tree-optimization/52345] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-02-22 21:45 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 52345
           Summary: Missed optimization dealing with bools
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: pinskia@gcc.gnu.org


Take the following three functions:
int f(int a, int b)
{
  int c = a != 0;
  int d = (c!=0|b!=0);
  return d;
}

int f1(int a, int b)
{
  int c = a != 0;
  int e = c!=0;
  int h = b!=0;
  int d = e|h;
  return d;
}

int f2(int a, int b)
{
  return (a!=0|b!=0);
}

--- CUT ---
Right now only f2 produces good code while the other two are not so good.


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

* [Bug tree-optimization/52345] Missed optimization dealing with bools
  2012-02-22 21:45 [Bug tree-optimization/52345] New: Missed optimization dealing with bools pinskia at gcc dot gnu.org
@ 2012-02-22 22:05 ` pinskia at gcc dot gnu.org
  2023-09-16 19:51 ` pinskia at gcc dot gnu.org
  2023-09-16 20:05 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-02-22 22:05 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2012-02-22
     Ever Confirmed|0                           |1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-02-22 21:44:52 UTC ---
I have a fix in mind.


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

* [Bug tree-optimization/52345] Missed optimization dealing with bools
  2012-02-22 21:45 [Bug tree-optimization/52345] New: Missed optimization dealing with bools pinskia at gcc dot gnu.org
  2012-02-22 22:05 ` [Bug tree-optimization/52345] " pinskia at gcc dot gnu.org
@ 2023-09-16 19:51 ` pinskia at gcc dot gnu.org
  2023-09-16 20:05 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-16 19:51 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |pinskia at gcc dot gnu.org

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
// (a | zero_one) != 0 -> a!=0 | zero_one

(simplify
 (ne (bit_ior:c @1 zero_one_value_p@2) integer_zerop@3)
 (bit_ior (convert @1) (ne @2 @3)))


// (a & zero_one) != 0 -> a==0 & (zero_one^1)
(simplify
 (eq (bit_and:c @1 zero_one_value_p@2) integer_zerop@3)
 (bit_and
  (convert (bit_xor @1 { build_one_cst (TREE_TYPE (@1)); } ))
  (ne @2 @3)))


Similar to:
https://gcc.gnu.org/pipermail/gcc-patches/2023-September/630651.html

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

* [Bug tree-optimization/52345] Missed optimization dealing with bools
  2012-02-22 21:45 [Bug tree-optimization/52345] New: Missed optimization dealing with bools pinskia at gcc dot gnu.org
  2012-02-22 22:05 ` [Bug tree-optimization/52345] " pinskia at gcc dot gnu.org
  2023-09-16 19:51 ` pinskia at gcc dot gnu.org
@ 2023-09-16 20:05 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-16 20:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---

(In reply to Andrew Pinski from comment #5)
> // (a | zero_one) != 0 -> a!=0 | zero_one
> 
> (simplify
>  (ne (bit_ior:c @1 zero_one_value_p@2) integer_zerop@3)
>  (bit_ior (convert @1) (ne @2 @3)))
> 
> 
> // (a & zero_one) != 0 -> a==0 & (zero_one^1)
Should have been:
  // (a & zero_one) == 0 -> a==0 & (zero_one^1)

> (simplify
>  (eq (bit_and:c @1 zero_one_value_p@2) integer_zerop@3)
>  (bit_and
>   (convert (bit_xor @1 { build_one_cst (TREE_TYPE (@1)); } ))
>   (ne @2 @3)))
> 
> 
> Similar to:
> https://gcc.gnu.org/pipermail/gcc-patches/2023-September/630651.html

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

end of thread, other threads:[~2023-09-16 20:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-22 21:45 [Bug tree-optimization/52345] New: Missed optimization dealing with bools pinskia at gcc dot gnu.org
2012-02-22 22:05 ` [Bug tree-optimization/52345] " pinskia at gcc dot gnu.org
2023-09-16 19:51 ` pinskia at gcc dot gnu.org
2023-09-16 20:05 ` 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).