public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/54733] New: Missing opportunity to optimize endian independent load/store
@ 2012-09-28 10:03 joey.ye at arm dot com
  2012-09-28 10:47 ` [Bug tree-optimization/54733] " rguenth at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: joey.ye at arm dot com @ 2012-09-28 10:03 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 54733
           Summary: Missing opportunity to optimize endian independent
                    load/store
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: joey.ye@arm.com


This case tries to load from memory in little-endian way, no matter what
endianess current target is.

On trunk 4.8 little-endian target, two byte loads should be able to combined
into a single 16-byte load.

int read_aux(void *, int);

int read_le()
{ 
    unsigned char data[2]; 
    read_aux(data, 2); 
    return data[0] | (data[1]<<8);
}

Current Tree (optimized):
  unsigned char data[2];

  read_aux (&data, 2);
  D.4064_1 = data[0];
  D.4065_2 = (int) D.4064_1;
  D.4066_3 = data[1];
  D.4067_4 = (int) D.4066_3;
  D.4068_5 = D.4067_4 << 8;
  D.4063_6 = D.4068_5 | D.4065_2;
  data ={v} {CLOBBER};
  return D.4063_6;

Expected Tree (optimized):
  unsigned char data[2];
  unsigned short *temp;
  unsigned in D.4064;

  read_aux (&data, 2);
  temp=&data;
  D.4064_1 = *temp;
  return D.4064_1;


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

* [Bug tree-optimization/54733] Missing opportunity to optimize endian independent load/store
  2012-09-28 10:03 [Bug tree-optimization/54733] New: Missing opportunity to optimize endian independent load/store joey.ye at arm dot com
@ 2012-09-28 10:47 ` rguenth at gcc dot gnu.org
  2014-03-19  6:31 ` thomas.preudhomme at arm dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-09-28 10:47 UTC (permalink / raw)
  To: gcc-bugs


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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-09-28
     Ever Confirmed|0                           |1

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-09-28 10:47:44 UTC ---
Confirmed.  The original idea was to leverage the byte-swap pass for this.
First you need to extend that to work on a memory source (which it currently
does not handle), then you, in addition to detecting bswap, emit a word
load and detect the "noop" pattern which then skips bswap.  (the byte-swap
pass was also supposed to utilize the vector shuffle engine for non-bswap
shuffles).


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

* [Bug tree-optimization/54733] Missing opportunity to optimize endian independent load/store
  2012-09-28 10:03 [Bug tree-optimization/54733] New: Missing opportunity to optimize endian independent load/store joey.ye at arm dot com
  2012-09-28 10:47 ` [Bug tree-optimization/54733] " rguenth at gcc dot gnu.org
@ 2014-03-19  6:31 ` thomas.preudhomme at arm dot com
  2014-05-23  3:34 ` thopre01 at gcc dot gnu.org
  2014-05-26 13:49 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: thomas.preudhomme at arm dot com @ 2014-03-19  6:31 UTC (permalink / raw)
  To: gcc-bugs

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

Thomas Preud'homme <thomas.preudhomme at arm dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |thomas.preudhomme at arm dot com

--- Comment #2 from Thomas Preud'homme <thomas.preudhomme at arm dot com> ---
A patch to fix this is currently under discussion on gcc-patches at:

http://gcc.gnu.org/ml/gcc-patches/2014-03/msg00925.html


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

* [Bug tree-optimization/54733] Missing opportunity to optimize endian independent load/store
  2012-09-28 10:03 [Bug tree-optimization/54733] New: Missing opportunity to optimize endian independent load/store joey.ye at arm dot com
  2012-09-28 10:47 ` [Bug tree-optimization/54733] " rguenth at gcc dot gnu.org
  2014-03-19  6:31 ` thomas.preudhomme at arm dot com
@ 2014-05-23  3:34 ` thopre01 at gcc dot gnu.org
  2014-05-26 13:49 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: thopre01 at gcc dot gnu.org @ 2014-05-23  3:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from thopre01 at gcc dot gnu.org ---
Author: thopre01
Date: Fri May 23 03:33:28 2014
New Revision: 210843

URL: http://gcc.gnu.org/viewcvs?rev=210843&root=gcc&view=rev
Log:
2014-05-23  Thomas Preud'homme  <thomas.preudhomme@arm.com>

    PR tree-optimization/54733
gcc/
    * tree-ssa-math-opts.c (nop_stats): New "bswap_stats" structure.
    (CMPNOP): Define.
    (find_bswap_or_nop_load): New.
    (find_bswap_1): Renamed to ...
    (find_bswap_or_nop_1): This. Also add support for memory source.
    (find_bswap): Renamed to ...
    (find_bswap_or_nop): This. Also add support for memory source and
    detection of bitwise operations equivalent to load in host endianness.
    (execute_optimize_bswap): Likewise. Also move its leading comment back
    in place and split statement transformation into ...
    (bswap_replace): This.

gcc/testsuite
    * gcc.dg/optimize-bswapdi-3.c: New test to check extension of bswap
    optimization to support memory sources and bitwise operations
    equivalent to load in host endianness.
    * gcc.dg/optimize-bswaphi-1.c: Likewise.
    * gcc.dg/optimize-bswapsi-2.c: Likewise.
    * gcc.c-torture/execute/bswap-2.c: Likewise.

Added:
    trunk/gcc/testsuite/gcc.c-torture/execute/bswap-2.c
    trunk/gcc/testsuite/gcc.dg/optimize-bswapdi-3.c
    trunk/gcc/testsuite/gcc.dg/optimize-bswaphi-1.c
    trunk/gcc/testsuite/gcc.dg/optimize-bswapsi-2.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-math-opts.c


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

* [Bug tree-optimization/54733] Missing opportunity to optimize endian independent load/store
  2012-09-28 10:03 [Bug tree-optimization/54733] New: Missing opportunity to optimize endian independent load/store joey.ye at arm dot com
                   ` (2 preceding siblings ...)
  2014-05-23  3:34 ` thopre01 at gcc dot gnu.org
@ 2014-05-26 13:49 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-05-26 13:49 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |4.10.0

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.


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

end of thread, other threads:[~2014-05-26 13:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-28 10:03 [Bug tree-optimization/54733] New: Missing opportunity to optimize endian independent load/store joey.ye at arm dot com
2012-09-28 10:47 ` [Bug tree-optimization/54733] " rguenth at gcc dot gnu.org
2014-03-19  6:31 ` thomas.preudhomme at arm dot com
2014-05-23  3:34 ` thopre01 at gcc dot gnu.org
2014-05-26 13:49 ` rguenth 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).