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 rtl-optimization/37262] New: Two branches of the same condition being emitted


Take:
unsigned ReverseBits (unsigned index, unsigned NumBits)
{
  unsigned i, rev;

  for (i = rev = 0; i < NumBits; i++)
  {
    rev = (rev << 1) | (index & 1);
    index >>= 1;
  }
  return rev;
}
---- CUT ---
Currently we get:
        mtctr 9
        beq- 7,.L8
        beq- 7,.L8
        .p2align 3,,7

Which is obviously broken as we should have only one beq as they use the same
CR and go to the same block and there is no way to get to the second one
without going through the first.

4.1.1 -fno-ivopts produces even worse code:
        cmplwi 7,4,1
        blt- 7,.L8
        cmpwi 7,4,0
        beq- 7,.L8

But we know that this a logicial compare so r4 < 1 is the same as r4 ==0 so 4.3
produces better code but still needs slight improvement with respect of getting
rid of the extra branch (though we have regression between 4.1 and 4.3 which I
will file seperately as it is unrelated to this bug).


-- 
           Summary: Two branches of the same condition being emitted
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pinskia at gcc dot gnu dot org
GCC target triplet: powerpc64-linux-gnu


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


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