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 tree-optimization/70527] New: Missed fold for "(long int) x * 12 - (long int)(x + 1) * 12"


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

            Bug ID: 70527
           Summary: Missed fold for "(long int) x * 12 - (long int)(x + 1)
                    * 12"
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: amker at gcc dot gnu.org
  Target Milestone: ---

Given below test:
long unsigned int foo (int x)
{
  return (long unsigned int) x * 12 - (long unsigned int)(x + 1) * 12;
}

long int bar (int x)
{
  return (long int) x * 12 - (long int)(x + 1) * 12;
}
The 004t.gimple dump is like:
foo (int x)
{
  long unsigned int D.1762;

  D.1762 = 18446744073709551604;
  return D.1762;
}


bar (int x)
{
  long int D.1764;
  long int D.1765;
  long int D.1766;
  int D.1767;
  long int D.1768;
  long int D.1769;

  D.1765 = (long int) x;
  D.1766 = D.1765 * 12;
  D.1767 = x + 1;
  D.1768 = (long int) D.1767;
  D.1769 = D.1768 * -12;
  D.1764 = D.1766 + D.1769;
  return D.1764;
}


Seems "(long int) x * 12 - (long int)(x + 1) * 12" is missed in
generic-simplify.

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