[Bug tree-optimization/17116] New: Missed optimization with loop and % (or ands)

pinskia at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Fri Aug 20 07:12:00 GMT 2004


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



More information about the Gcc-bugs mailing list