public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/63568] New: Missed optimization (a & ~mask) | (b & mask) = a ^ ((a ^ b) & mask)
@ 2014-10-16 23:55 olegendo at gcc dot gnu.org
  2014-10-17  8:31 ` [Bug tree-optimization/63568] " rguenth at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: olegendo at gcc dot gnu.org @ 2014-10-16 23:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63568

            Bug ID: 63568
           Summary: Missed optimization (a & ~mask) | (b & mask) = a ^ ((a
                    ^ b) & mask)
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: olegendo at gcc dot gnu.org
            Target: sh*-*-*

As of 216350, compiling the following example on SH with -O2

unsigned int test (unsigned int a, unsigned int b, unsigned int m)
{
  return (a & ~m) | (b & m);
}

results in:
        not     r6,r0
        and     r0,r4
        and     r6,r5
        mov     r4,r0
        rts
        or      r5,r0

A shorter way is to do the same is:
        xor     r4,r5
        and     r5,r6
        mov     r6,r0
        rts
        xor     r4,r0

If this kind of stuff is done as part of tree optimization, then this is
probably not SH specific, although I haven't checked with other targets.


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

end of thread, other threads:[~2014-12-17 11:55 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-16 23:55 [Bug tree-optimization/63568] New: Missed optimization (a & ~mask) | (b & mask) = a ^ ((a ^ b) & mask) olegendo at gcc dot gnu.org
2014-10-17  8:31 ` [Bug tree-optimization/63568] " rguenth at gcc dot gnu.org
2014-12-16 11:18 ` mpolacek at gcc dot gnu.org
2014-12-16 13:44 ` [Bug middle-end/63568] " mpolacek at gcc dot gnu.org
2014-12-16 13:50 ` jakub at gcc dot gnu.org
2014-12-16 14:17 ` mpolacek at gcc dot gnu.org
2014-12-16 14:21 ` rguenther at suse dot de
2014-12-16 20:38 ` olegendo at gcc dot gnu.org
2014-12-17 11:49 ` mpolacek at gcc dot gnu.org
2014-12-17 11:55 ` mpolacek 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).