public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/19791] New: [tcb] A constant not fully propagated
@ 2005-02-06 13:21 kazu@cs.umass.edu
  2005-02-06 15:34 ` [Bug tree-optimization/19791] " kazu@cs.umass.edu
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: kazu@cs.umass.edu @ 2005-02-06 13:21 UTC (permalink / raw)
  To: gcc-bugs

Consider:

extern void abort (void) __attribute__ ((__noreturn__));

extern int bar (int, int);

int
foo (int mode, int size, unsigned int align)
{
  int align0;
  int iftmp1;

  if (mode == 0)
    {
      if (align != 128)
	abort ();
    }

  align0 = (int) align;
  if (mode == 0)
    {
      int D1131 = align0 / 8;
      int D1132 = D1131 + size;
      int D1133 = D1132 - 1;
      int D1134 = D1131 - 1;
      int D1135 = ~D1134;

      iftmp1 = D1133 & D1135;
    }
  else
    {
      iftmp1 = size;
    }

  return bar (iftmp1, align0);
}

Note that if we get to the basic block that starts with "int D1131",
we know that align0 == 128, which can be propagated.

The last tree SSA dump looks like so:

foo (mode, size, align)
{
  int prephitmp.1;
  int pretmp.0;
  int D1135;
  int D1134;
  int D1133;
  int D1132;
  int D1131;
  int iftmp1;
  int align0;
  int D.1134;
  int D.1133;

<bb 0>:
  if (mode_4 == 0) goto <L0>; else goto <L10>;

<L0>:;
  if (align_6 != 128) goto <L1>; else goto <L13>;

<L1>:;
  abort ();

<L10>:;
  align0_5 = (int) align_6;

Invalid sum of outgoing probabilities 0.0%
Invalid sum of incoming frequencies 5000, should be 0
  # align0_2 = PHI <align0_5(3)>;
<L2>:;

Invalid sum of incoming frequencies 0, should be 9950
  # align0_7 = PHI <align0_9(6), align0_2(4)>;
  # iftmp1_3 = PHI <iftmp1_18(6), size_11(4)>;
<L6>:;
  D.1133_8 = bar (iftmp1_3, align0_7) [tail call];
  return D.1133_8;

Invalid sum of incoming frequencies 4950, should be 0
  # align0_9 = PHI <128(1)>;
<L13>:;
  D1131_13 = align0_9 / 8;
  D1132_14 = size_11 + D1131_13;
  D1133_15 = D1132_14 - 1;
  D1134_16 = D1131_13 - 1;
  D1135_17 = ~D1134_16;
  iftmp1_18 = D1133_15 & D1135_17;
  goto <bb 5> (<L6>);

}

Notice

  # align0_9 = PHI <128(1)>;

which means we are missing the obvious constant propagation opportunity.

This opportunity is picked up at the RTL level.

On mainline, the opportunity is not as obvious, but the RTL optimizers do
take care of this.

-- 
           Summary: [tcb] A constant not fully propagated
           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=19791


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

* [Bug tree-optimization/19791] [tcb] A constant not fully propagated
  2005-02-06 13:21 [Bug tree-optimization/19791] New: [tcb] A constant not fully propagated kazu@cs.umass.edu
@ 2005-02-06 15:34 ` kazu@cs.umass.edu
  2005-02-06 16:17 ` pinskia@gcc.gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: kazu@cs.umass.edu @ 2005-02-06 15:34 UTC (permalink / raw)
  To: gcc-bugs

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
OtherBugsDependingO|                            |19721
              nThis|                            |


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


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

* [Bug tree-optimization/19791] [tcb] A constant not fully propagated
  2005-02-06 13:21 [Bug tree-optimization/19791] New: [tcb] A constant not fully propagated kazu@cs.umass.edu
  2005-02-06 15:34 ` [Bug tree-optimization/19791] " kazu@cs.umass.edu
@ 2005-02-06 16:17 ` pinskia@gcc.gnu.org
  2005-05-06  8:39 ` steven at gcc dot gnu dot org
  2005-05-06 14:02 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia@gcc.gnu.org @ 2005-02-06 16:17 UTC (permalink / raw)
  To: gcc-bugs

------- Additional Comments From pinskia at gcc dot gnu dot org  2005-02-06 16:25 -------
Confirmed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2005-02-06 16:25:18
               date|                            |


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


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

* [Bug tree-optimization/19791] [tcb] A constant not fully propagated
  2005-02-06 13:21 [Bug tree-optimization/19791] New: [tcb] A constant not fully propagated kazu@cs.umass.edu
  2005-02-06 15:34 ` [Bug tree-optimization/19791] " kazu@cs.umass.edu
  2005-02-06 16:17 ` pinskia@gcc.gnu.org
@ 2005-05-06  8:39 ` steven at gcc dot gnu dot org
  2005-05-06 14:02 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: steven at gcc dot gnu dot org @ 2005-05-06  8:39 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From steven at gcc dot gnu dot org  2005-05-06 08:39 -------
Looks fixed to me. 
 
The only problem now is that there is an extra load of 128 as an immediate, 
I haven't looked at why uncprop doesn't fix this. 
 
--------------------------- 
extern void abort (void) __attribute__ ((__noreturn__)); 
 
extern int bar (int, int); 
 
int 
PR19791_test (int mode, int size, unsigned int align) 
{ 
  int align0; 
  int iftmp1; 
 
  if (mode == 0) 
    { 
      if (align != 128) 
        abort (); 
    } 
 
  align0 = (int) align; 
  if (mode == 0) 
    { 
      int D1131 = align0 / 8; 
      int D1132 = D1131 + size; 
      int D1133 = D1132 - 1; 
      int D1134 = D1131 - 1; 
      int D1135 = ~D1134; 
 
      iftmp1 = D1133 & D1135; 
    } 
  else 
    { 
      iftmp1 = size; 
    } 
 
  return bar (iftmp1, align0); 
} 
 
 
int 
PR19791_result (int mode, int size, unsigned int align) 
{ 
  int align0; 
  int iftmp1; 
 
  if (mode == 0) 
    { 
      if (align != 128) 
        abort (); 
    } 
 
  align0 = (int) align; 
  if (mode == 0) 
    { 
      int D1131 = ((int) 128) / 8; 
      int D1132 = D1131 + size; 
      int D1133 = D1132 - 1; 
      int D1134 = D1131 - 1; 
      int D1135 = ~D1134; 
 
      iftmp1 = D1133 & D1135; 
    } 
  else 
    { 
      iftmp1 = size; 
    } 
 
  return bar (iftmp1, align0); 
} 
--------------------------- 
 
--------------------------- 
PR19791_test (mode, size, align) 
{ 
  int D1135; 
  int D1134; 
  int D1133; 
  int D1132; 
  int D1131; 
  int iftmp1; 
  int align0; 
  int D.1579; 
  int D.1578; 
 
<bb 0>: 
  if (mode == 0) goto <L0>; else goto <L2>; 
 
<L0>:; 
  if (align != 128) goto <L1>; else goto <L4>; 
 
<L1>:; 
  abort (); 
 
<L2>:; 
  align0 = (int) align; 
  iftmp1 = size; 
  goto <bb 5> (<L6>); 
 
<L4>:; 
  iftmp1 = size + 15 & -16; 
  align0 = 128; 
 
<L6>:; 
  D.1578 = bar (iftmp1, align0) [tail call]; 
  return D.1578; 
 
} 
 
PR19791_result (mode, size, align) 
{ 
  int D1135; 
  int D1134; 
  int D1133; 
  int D1132; 
  int D1131; 
  int iftmp1; 
  int align0; 
  int D.1593; 
  int D.1592; 
 
<bb 0>: 
  if (mode == 0) goto <L0>; else goto <L2>; 
 
<L0>:; 
  if (align != 128) goto <L1>; else goto <L4>; 
 
<L1>:; 
  abort (); 
 
<L2>:; 
  align0 = (int) align; 
  iftmp1 = size; 
  goto <bb 5> (<L6>); 
 
<L4>:; 
  iftmp1 = size + 15 & -16; 
  align0 = 128; 
 
<L6>:; 
  D.1592 = bar (iftmp1, align0) [tail call]; 
  return D.1592; 
 
} 
--------------------------- 
 

-- 


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


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

* [Bug tree-optimization/19791] [tcb] A constant not fully propagated
  2005-02-06 13:21 [Bug tree-optimization/19791] New: [tcb] A constant not fully propagated kazu@cs.umass.edu
                   ` (2 preceding siblings ...)
  2005-05-06  8:39 ` steven at gcc dot gnu dot org
@ 2005-05-06 14:02 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-06 14:02 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-05-06 14:02 -------
Fixed by the new jump threader.

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


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


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

end of thread, other threads:[~2005-05-06 14:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-06 13:21 [Bug tree-optimization/19791] New: [tcb] A constant not fully propagated kazu@cs.umass.edu
2005-02-06 15:34 ` [Bug tree-optimization/19791] " kazu@cs.umass.edu
2005-02-06 16:17 ` pinskia@gcc.gnu.org
2005-05-06  8:39 ` steven at gcc dot gnu dot org
2005-05-06 14:02 ` 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).