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/17116] New: Missed optimization with loop and % (or ands)


main()
{
  int  i;
  for (i=0; i < 90; i++)
  {
    if (i%2)
        puts("hello");
  }
}

We get the following thing from .vars:
<bb 0>:
  i = 0;

<L0>:;
  if ((i & 1) != 0) goto <L1>; else goto <L2>;

when we should get:
<bb 0>:
  i = 0;
  goto <L2>;

<L0>:;
  if ((i & 1) != 0) goto <L1>; else goto <L2>;

Or we could just divide 90 by 2.

-- 
           Summary: Missed optimization with loop and % (or ands)
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pinskia at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


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


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