public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/56064] New: Optimize VIEW_CONVERT_EXPR with FIXED_CST
@ 2013-01-21 13:10 gjl at gcc dot gnu.org
  2013-01-30 11:04 ` [Bug tree-optimization/56064] " gjl at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: gjl at gcc dot gnu.org @ 2013-01-21 13:10 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 56064
           Summary: Optimize VIEW_CONVERT_EXPR with FIXED_CST
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: gjl@gcc.gnu.org


Created attachment 29235
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29235
foo.c.165r.expand (RTL dump)

In the followinf C code


static __inline__ __attribute__((__always_inline__))
_Fract rbits (const __INT16_TYPE__ i)
{
    _Fract f;
    __builtin_memcpy (&f, &i, sizeof (_Fract));
    return f;
}

_Fract func (void)
{
    return rbits (__INT16_C(0x1234));
}


The memcpy could be optimized away.  It is represented as VIEW_CONVERT_EXPR but
FIXED_CST is not folded in fold-const.c.

The attachment shows the memory moves of HQmode which is suboptimal.  For more
details, see http://gcc.gnu.org/ml/gcc/2013-01/msg00187.html


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

* [Bug tree-optimization/56064] Optimize VIEW_CONVERT_EXPR with FIXED_CST
  2013-01-21 13:10 [Bug tree-optimization/56064] New: Optimize VIEW_CONVERT_EXPR with FIXED_CST gjl at gcc dot gnu.org
@ 2013-01-30 11:04 ` gjl at gcc dot gnu.org
  2013-01-30 11:06 ` gjl at gcc dot gnu.org
  2013-02-08 13:24 ` gjl at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: gjl at gcc dot gnu.org @ 2013-01-30 11:04 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #1 from Georg-Johann Lay <gjl at gcc dot gnu.org> 2013-01-30 11:04:35 UTC ---
Author: gjl
Date: Wed Jan 30 11:04:30 2013
New Revision: 195574

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195574
Log:
gcc/
    PR tree-optimization/56064
    * fixed-value.c (fixed_from_double_int): New function.
    * fixed-value.h (fixed_from_double_int): New prototype.
    (const_fixed_from_double_int): New static inline function.
    * fold-const.c (native_interpret_fixed): New static function.
    (native_interpret_expr) <FIXED_POINT_TYPE>: Use it.
    (can_native_interpret_type_p) <FIXED_POINT_TYPE>: Return true.
    (native_encode_fixed): New static function.
    (native_encode_expr) <FIXED_CST>: Use it.
    (native_interpret_int): Move double_int worker code to...
    * double-int.c (double_int::from_buffer): ...this new static method.
    * double-int.h (double_int::from_buffer): Prototype it.

gcc/testsuite/
    PR tree-optimization/56064
    * gcc.dg/fixed-point/view-convert.c: New test.


Added:
    trunk/gcc/testsuite/gcc.dg/fixed-point/view-convert.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/double-int.c
    trunk/gcc/double-int.h
    trunk/gcc/fixed-value.c
    trunk/gcc/fixed-value.h
    trunk/gcc/fold-const.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug tree-optimization/56064] Optimize VIEW_CONVERT_EXPR with FIXED_CST
  2013-01-21 13:10 [Bug tree-optimization/56064] New: Optimize VIEW_CONVERT_EXPR with FIXED_CST gjl at gcc dot gnu.org
  2013-01-30 11:04 ` [Bug tree-optimization/56064] " gjl at gcc dot gnu.org
@ 2013-01-30 11:06 ` gjl at gcc dot gnu.org
  2013-02-08 13:24 ` gjl at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: gjl at gcc dot gnu.org @ 2013-01-30 11:06 UTC (permalink / raw)
  To: gcc-bugs


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

Georg-Johann Lay <gjl at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.8.0

--- Comment #2 from Georg-Johann Lay <gjl at gcc dot gnu.org> 2013-01-30 11:06:28 UTC ---
Done.


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

* [Bug tree-optimization/56064] Optimize VIEW_CONVERT_EXPR with FIXED_CST
  2013-01-21 13:10 [Bug tree-optimization/56064] New: Optimize VIEW_CONVERT_EXPR with FIXED_CST gjl at gcc dot gnu.org
  2013-01-30 11:04 ` [Bug tree-optimization/56064] " gjl at gcc dot gnu.org
  2013-01-30 11:06 ` gjl at gcc dot gnu.org
@ 2013-02-08 13:24 ` gjl at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: gjl at gcc dot gnu.org @ 2013-02-08 13:24 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #3 from Georg-Johann Lay <gjl at gcc dot gnu.org> 2013-02-08 13:23:46 UTC ---
Author: gjl
Date: Fri Feb  8 13:23:34 2013
New Revision: 195885

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195885
Log:
gcc/
    PR tree-optimization/56064
    * fixed-value.c (fixed_from_double_int): Sign/zero extend payload
    bits according to mode.
    * fixed-value.h (fixed_from_double_int)
    (const_fixed_from_double_int): Adjust comments.

gcc/testsuite/
    PR tree-optimization/56064
    * gcc.dg/fixed-point/view-convert-2.c: New test.


Added:
    trunk/gcc/testsuite/gcc.dg/fixed-point/view-convert-2.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/fixed-value.c
    trunk/gcc/fixed-value.h
    trunk/gcc/testsuite/ChangeLog


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

end of thread, other threads:[~2013-02-08 13:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-21 13:10 [Bug tree-optimization/56064] New: Optimize VIEW_CONVERT_EXPR with FIXED_CST gjl at gcc dot gnu.org
2013-01-30 11:04 ` [Bug tree-optimization/56064] " gjl at gcc dot gnu.org
2013-01-30 11:06 ` gjl at gcc dot gnu.org
2013-02-08 13:24 ` gjl 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).