This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug optimization/15255] New: [tree-ssa] a * 2 + a * 2 is not converted to a * 4


int
foo (int a)
{
  return a * 2 + a * 2;
}

The last SSA form looks like:

foo (a)
{
  int T.0;

<bb 0>:
  T.0_2 = a_1 + a_1;
  return T.0_2 * 2;

}

Why not return a_1 * 4?

Interestingly, a * 3 + a * 5 is converted to a * 8, but if I compute like so

int
foo (int a)
{
  int b = a * 3;
  int c = a * 5;
  return b + c;
}

I get:

  b_2 = a_1 * 3;
  c_3 = a_1 * 5;
  return b_2 + c_3;

-- 
           Summary: [tree-ssa] a * 2 + a * 2 is not converted to a * 4
           Product: gcc
           Version: tree-ssa
            Status: UNCONFIRMED
          Keywords: pessimizes-code
          Severity: enhancement
          Priority: P2
         Component: 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=15255


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]