public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/51781] New: Missed optimization for ==/!= comparison type-sinking
@ 2012-01-07 11:00 ktietz at gcc dot gnu.org
  2021-06-04 21:55 ` [Bug tree-optimization/51781] " pinskia at gcc dot gnu.org
  2023-05-15  4:09 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: ktietz at gcc dot gnu.org @ 2012-01-07 11:00 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 51781
           Summary: Missed optimization for ==/!= comparison type-sinking
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: ktietz@gcc.gnu.org
            Target: *-*-*


The following code shows an issue about missed optimization for ==/!=
comparisons.

extern unsigned char ar[256];

int foo (int x, int y)
{
  int i = (int) ar[x];
  return (i == (y & 0xff));
}

Compiled with 4.7 using -O2 we get the following optimized tree:

;; Function foo (foo, funcdef_no=0, decl_uid=1600, cgraph_uid=0)

foo (int x, int y)
{
  int i;
  _Bool D.2716;
  int D.2715;
  int D.2714;
  unsigned char D.2713;

<bb 2>:
  D.2713_2 = ar[x_1(D)];
  i_3 = (int) D.2713_2;
  D.2715_5 = y_4(D) & 255;
  D.2716_6 = D.2715_5 == i_3;
  D.2714_7 = (int) D.2716_6;
  return D.2714_7;

}

But to be expected would be:

;; Function foo (foo, funcdef_no=0, decl_uid=1709, cgraph_uid=0)

foo (int x, int y)
{
  unsigned char D.1719;
  _Bool D.1716;
  int D.1714;
  unsigned char D.1713;

<bb 2>:
  D.1713_2 = ar[x_1(D)];
  D.1719_9 = (unsigned char) y_4(D);
  D.1716_6 = D.1713_2 == D.1719_9;
  D.1714_7 = (int) D.1716_6;
  return D.1714_7;

}


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

* [Bug tree-optimization/51781] Missed optimization for ==/!= comparison type-sinking
  2012-01-07 11:00 [Bug tree-optimization/51781] New: Missed optimization for ==/!= comparison type-sinking ktietz at gcc dot gnu.org
@ 2021-06-04 21:55 ` pinskia at gcc dot gnu.org
  2023-05-15  4:09 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-06-04 21:55 UTC (permalink / raw)
  To: gcc-bugs

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

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 #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Mine.

Psedu-match.pd code (needs expansion of some stuff but the general idea is
there)
(for (cmp ne eq)
 (cmp (convert @0) (bit_and @1 INTEGER_CST@2)
  (if (TYPE_UNSIGNED(@0) && @2 == maskforprecissionoftype(@0))
   (cmp @0 (convert:TYPE(@0) @1))

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

* [Bug tree-optimization/51781] Missed optimization for ==/!= comparison type-sinking
  2012-01-07 11:00 [Bug tree-optimization/51781] New: Missed optimization for ==/!= comparison type-sinking ktietz at gcc dot gnu.org
  2021-06-04 21:55 ` [Bug tree-optimization/51781] " pinskia at gcc dot gnu.org
@ 2023-05-15  4:09 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-15  4:09 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
No longer working on this one.

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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-07 11:00 [Bug tree-optimization/51781] New: Missed optimization for ==/!= comparison type-sinking ktietz at gcc dot gnu.org
2021-06-04 21:55 ` [Bug tree-optimization/51781] " pinskia at gcc dot gnu.org
2023-05-15  4:09 ` 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).