public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
[parent not found: <bug-19790-4@http.gcc.gnu.org/bugzilla/>]
[parent not found: <bug-19790-5009@http.gcc.gnu.org/bugzilla/>]
* [Bug tree-optimization/19790] New: equality not noticed when signedness differs.
@ 2005-02-06 13:21 kazu@cs.umass.edu
  2005-02-06 13:21 ` [Bug tree-optimization/19790] " kazu@cs.umass.edu
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: kazu@cs.umass.edu @ 2005-02-06 13:21 UTC (permalink / raw)
  To: gcc-bugs

Consider:

extern void bar (int);

foo (int *array)
{
  int i;

  for (i = 0; i <= 10; i++)
    {
      bar (i + 1);
      array[i / ((unsigned) 32)] |= ((unsigned long) 1) << (i % ((unsigned) (32)));
    }
}

The last tree SSA dump looks like so:

foo (array)
{
  unsigned int D.1154;
  unsigned int D.1152;
  unsigned int D.1153;
  unsigned int ivtmp.5;
  int pretmp.4;
  unsigned int pretmp.3;
  int pretmp.2;
  int i;
  int D.1136;
  long unsigned int D.1135;
  long unsigned int D.1134;
  int D.1133;
  long unsigned int D.1132;
  int D.1131;
  int * D.1130;
  int * D.1129;
  unsigned int D.1128;
  unsigned int D.1127;
  unsigned int i.0;
  int D.1125;

<bb 0>:

  # i_24 = PHI <i_1(1), 0(0)>;
<L0>:;
  D.1152_7 = (unsigned int) i_24;
  D.1153_20 = D.1152_7 + 1;
  i_1 = (int) D.1153_20;
  bar (i_1);
  D.1154_27 = (unsigned int) i_1;
  i.0_28 = D.1154_27 + 0ffffffff;
  D.1127_5 = i.0_28 >> 5;
  D.1128_10 = D.1127_5 * 4;
  D.1129_11 = (int *) D.1128_10;
  D.1130_12 = array_8 + D.1129_11;
  D.1131_13 = *D.1130_12;
  D.1132_14 = (long unsigned int) D.1131_13;
  D.1133_15 = i_24 & 31;
  D.1134_16 = 1 << D.1133_15;
  D.1135_17 = D.1132_14 | D.1134_16;
  D.1136_18 = (int) D.1135_17;
  *D.1130_12 = D.1136_18;
  if (D.1153_20 != 11) goto <L0>; else goto <L2>;

<L2>:;
  return;

}

Note that D.1152_7 == i.0_28, but this equality is not noticed
at tree level due to signedness changes in between.

We should replace the definition of i.0_28 as

  i.0_28 = D.1152_7;

and the copy propagation should take care of the rest.

The rtl optimizers catch this opportunity.

-- 
           Summary: equality not noticed when signedness differs.
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Keywords: missed-optimization, TREE
          Severity: enhancement
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kazu at cs dot umass dot edu
                CC: gcc-bugs at gcc dot gnu dot org


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


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

end of thread, other threads:[~2014-10-31  4:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20050206132852.19790.kazu@gcc.gnu.org>
2005-09-21  1:57 ` [Bug tree-optimization/19790] equality not noticed when signedness differs pinskia at gcc dot gnu dot org
     [not found] <bug-19790-4@http.gcc.gnu.org/bugzilla/>
2014-10-31  4:02 ` pinskia at gcc dot gnu.org
     [not found] <bug-19790-5009@http.gcc.gnu.org/bugzilla/>
2008-07-06  9:38 ` steven at gcc dot gnu dot org
2008-07-06 12:21 ` rguenth at gcc dot gnu dot org
2008-09-09  1:53 ` pinskia at gcc dot gnu dot org
2005-02-06 13:21 [Bug tree-optimization/19790] New: " kazu@cs.umass.edu
2005-02-06 13:21 ` [Bug tree-optimization/19790] " kazu@cs.umass.edu
2005-02-06 15:34 ` kazu@cs.umass.edu
2005-02-06 16:12 ` pinskia@gcc.gnu.org
2005-05-04 20:31 ` pinskia at gcc dot gnu dot 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).