public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/56552] New: conditional move can generate unnecessary conversion code
@ 2013-03-06 18:19 sje at gcc dot gnu.org
  2013-03-07 10:06 ` [Bug middle-end/56552] " rguenth at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: sje at gcc dot gnu.org @ 2013-03-06 18:19 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 56552
           Summary: conditional move can generate unnecessary conversion
                    code
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: sje@gcc.gnu.org
            Target: mips*-*-*


With this test program:

unsigned short foo(unsigned short a1, unsigned short a2)
{
  unsigned short i, x;
  for (i = 0; i < 8; i++) {
    x = (a1 & 1) ^ (a2 & 1);
    a1 >>= 1;
    if (x == 1) a2 ^= 0x2006;
    a2 >>= 1;
    if (x == 1) a2 |= 0x8800;
    else        a2 &= 0x77ff;
  }
  return a2;
}

The GCC 4.8 MIPS compiler generates a 'andi r,r,0xffff' instruction after
a movz (conditional move) that was not present in GCC 4.7.  This instruction
is generated because MIPS does not implement a 'short' conditional move so
expand_cond_expr_using_cmove promotes the mode then it has to 'demote' it back
to short and that generates the andi instruction.  But if the source and
destination of the conditional move are both shorts to begin with this andi
instruction is not needed.

The problem was fixed with this patch:

http://gcc.gnu.org/ml/gcc-patches/2012-11/msg01148.html

However it caused bug PR56548 (ICE on x86) and the fix for that
bug causes the extra andi instruction to once again be generated.


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

end of thread, other threads:[~2014-11-22 22:00 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-06 18:19 [Bug middle-end/56552] New: conditional move can generate unnecessary conversion code sje at gcc dot gnu.org
2013-03-07 10:06 ` [Bug middle-end/56552] " rguenth at gcc dot gnu.org
2013-03-07 13:32 ` jakub at gcc dot gnu.org
2013-03-07 14:53 ` pinskia at gcc dot gnu.org
2013-05-16 19:48 ` rsandifo at gcc dot gnu.org
2013-05-16 19:51 ` rsandifo at gcc dot gnu.org
2013-10-22 23:21 ` sje at gcc dot gnu.org
2013-11-18 19:20 ` sje at gcc dot gnu.org
2014-11-22 22:00 ` pinskia at gcc dot gnu.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).