[Bug tree-optimization/43037] New: re-association doesn't handle multiple uses with constant operands

rguenth at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Thu Feb 11 15:56:00 GMT 2010


int a, b;
void foo (int i, int x)
{
  int j, k, l;
  j = i * x;
  j = j * 5;
  k = j * 3;
  l = j * 4;
  a = k;
  b = l;
}

  j_3 = i_1(D) * 5;
  j_4 = j_3 * x_2(D);
  k_5 = j_4 * 3;
  l_6 = j_4 * 4;

should be re-associated and simplified to

  D.1_3 = i_1(D) * x_2(D);
  k_5 = D.1_3 * 15;
  l_6 = D.1_3 * 20;

note that this requires a value that is not computed previously and thus
is only profitable if all uses of j_4 will be dead after the transformation
unless it is possible to compute j_4 in terms of the new value with the
same number of operations.


-- 
           Summary: re-association doesn't handle multiple uses with
                    constant operands
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rguenth at gcc dot gnu dot org


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



More information about the Gcc-bugs mailing list