public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/55177] New: Missed optimisation: bswap, mask with constant, bswap back again.
@ 2012-11-02  9:59 dwmw2 at infradead dot org
  2012-11-02 10:46 ` [Bug tree-optimization/55177] " dwmw2 at infradead dot org
                   ` (22 more replies)
  0 siblings, 23 replies; 24+ messages in thread
From: dwmw2 at infradead dot org @ 2012-11-02  9:59 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 55177
           Summary: Missed optimisation: bswap, mask with constant, bswap
                    back again.
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: dwmw2@infradead.org


extern int x;

void foo(void)
{
  int a = __builtin_bswap32(x);
  a &= 0x5a5b5c5d;
  x = __builtin_bswap32(a);
}

With GCC 4.7.2 (x86_64 Fedora) this compiles to:
foo:
.LFB0:
    .cfi_startproc
    movl    x(%rip), %eax
    bswap    %eax
    andl    $-1515936861, %eax
    bswap    %eax
    movl    %eax, x(%rip)
    ret
    .cfi_endproc


Surely the actual swap should be optimised out, and the 0x5a5b5c5d constant
mask should be swapped instead so we just load, mask with 0x5d5c5b5a and store
without any runtime swapping?

(See also PR42586 which may be related)


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

end of thread, other threads:[~2021-11-17 23:41 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-02  9:59 [Bug tree-optimization/55177] New: Missed optimisation: bswap, mask with constant, bswap back again dwmw2 at infradead dot org
2012-11-02 10:46 ` [Bug tree-optimization/55177] " dwmw2 at infradead dot org
2012-11-02 10:56 ` [Bug rtl-optimization/55177] missed optimizations with __builtin_bswap ebotcazou at gcc dot gnu.org
2012-11-02 17:05 ` dwmw2 at infradead dot org
2012-11-02 17:46 ` ebotcazou at gcc dot gnu.org
2012-11-02 19:42 ` dwmw2 at infradead dot org
2012-11-02 21:59 ` ebotcazou at gcc dot gnu.org
2012-11-08 14:30 ` dwmw2 at infradead dot org
2012-11-08 16:14 ` ebotcazou at gcc dot gnu.org
2013-03-08 12:12 ` dwmw2 at infradead dot org
2013-03-08 15:19 ` pinskia at gcc dot gnu.org
2013-03-09  0:06 ` ebotcazou at gcc dot gnu.org
2013-03-09  0:16 ` [Bug tree-optimization/55177] " pinskia at gcc dot gnu.org
2014-04-04 12:40 ` krebbel at gcc dot gnu.org
2014-11-22 22:11 ` pinskia at gcc dot gnu.org
2015-01-23 14:00 ` ubizjak at gmail dot com
2015-01-23 14:08 ` dwmw2 at infradead dot org
2015-01-23 14:11 ` ubizjak at gmail dot com
2021-11-15  8:30 ` pinskia at gcc dot gnu.org
2021-11-15  8:35 ` pinskia at gcc dot gnu.org
2021-11-15  9:19 ` pinskia at gcc dot gnu.org
2021-11-17 23:40 ` cvs-commit at gcc dot gnu.org
2021-11-17 23:40 ` pinskia at gcc dot gnu.org
2021-11-17 23:41 ` 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).