public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/37262]  New: Two branches of the same condition being emitted
@ 2008-08-28  2:03 pinskia at gcc dot gnu dot org
  2008-08-29  4:39 ` [Bug rtl-optimization/37262] " pinskia at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-08-28  2:03 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug rtl-optimization/37262] Two branches of the same condition being emitted
  2008-08-28  2:03 [Bug rtl-optimization/37262] New: Two branches of the same condition being emitted pinskia at gcc dot gnu dot org
@ 2008-08-29  4:39 ` pinskia at gcc dot gnu dot org
  2008-08-30  1:43 ` pinskia at gcc dot gnu dot org
  2010-03-02 18:29 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-08-29  4:39 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug rtl-optimization/37262] Two branches of the same condition being emitted
  2008-08-28  2:03 [Bug rtl-optimization/37262] New: Two branches of the same condition being emitted pinskia at gcc dot gnu dot org
  2008-08-29  4:39 ` [Bug rtl-optimization/37262] " pinskia at gcc dot gnu dot org
@ 2008-08-30  1:43 ` pinskia at gcc dot gnu dot org
  2010-03-02 18:29 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-08-30  1:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2008-08-30 01:41 -------
I have seen this in other cases even for the non doloop case, though I don't
know if it is because of -O1 or because it is not removing it.
Testcase:
int _bfd_xcoff_canonicalize_dynamic_reloc (unsigned long long l_symndx)
{
  if (l_symndx < 3)
    {
      switch (l_symndx)
      {
        case 0:
        case 1:
         break;
        case 2:
         return _bfd_abort ();
    }
  }
}
--- CUT ---
Compile at -O1 on powerpc-linux and you will see the double branches:
        bne 0,.L7
        bne 0,.L8


-- 


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug rtl-optimization/37262] Two branches of the same condition being emitted
  2008-08-28  2:03 [Bug rtl-optimization/37262] New: Two branches of the same condition being emitted pinskia at gcc dot gnu dot org
  2008-08-29  4:39 ` [Bug rtl-optimization/37262] " pinskia at gcc dot gnu dot org
  2008-08-30  1:43 ` pinskia at gcc dot gnu dot org
@ 2010-03-02 18:29 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2010-03-02 18:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2010-03-02 18:29 -------
Still happens as of today on the trunk.


-- 


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-03-02 18:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-28  2:03 [Bug rtl-optimization/37262] New: Two branches of the same condition being emitted pinskia at gcc dot gnu dot org
2008-08-29  4:39 ` [Bug rtl-optimization/37262] " pinskia at gcc dot gnu dot org
2008-08-30  1:43 ` pinskia at gcc dot gnu dot org
2010-03-02 18:29 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).