public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/30354]  New: -Os doesn't optimize a/CONST even if it saves size.
@ 2007-01-02 22:09 vda dot linux at googlemail dot com
  2007-01-02 22:45 ` [Bug target/30354] " pinskia at gcc dot gnu dot org
                   ` (13 more replies)
  0 siblings, 14 replies; 18+ messages in thread
From: vda dot linux at googlemail dot com @ 2007-01-02 22:09 UTC (permalink / raw)
  To: gcc-bugs

gcc -O2 usually optimizes a/CONST. In many cases code is not only significantly
faster, but also smaller:

unsigned f(unsigned a) { return a/10; }

gcc 4.1.1 -O2:
        movl    $-858993459, %eax
        mull    4(%esp)
        shrl    $3, %edx
        movl    %edx, %eax
        ret

gcc 4.1.1 -Os:
        movl    4(%esp), %eax
        movl    $10, %edx
        movl    %edx, %ecx
        xorl    %edx, %edx
        divl    %ecx
        ret

Unfortunately, gcc -S never uses this optimization.

Note that with code proposed in bug 28417 a/CONST can be optimized even further
(we can use smaller mul constant and avoid shrl) when we know from VRP that
value of a is always small enough.


-- 
           Summary: -Os doesn't optimize a/CONST even if it saves size.
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: vda dot linux at googlemail dot com
 GCC build triplet: i386-pc-linux-gnu
  GCC host triplet: i386-pc-linux-gnu
GCC target triplet: i386-pc-linux-gnu


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


^ permalink raw reply	[flat|nested] 18+ messages in thread
[parent not found: <bug-30354-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2021-12-21 11:42 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-02 22:09 [Bug rtl-optimization/30354] New: -Os doesn't optimize a/CONST even if it saves size vda dot linux at googlemail dot com
2007-01-02 22:45 ` [Bug target/30354] " pinskia at gcc dot gnu dot org
2007-07-25 15:05 ` vda dot linux at googlemail dot com
2007-07-25 15:09 ` vda dot linux at googlemail dot com
2007-07-25 15:17 ` vda dot linux at googlemail dot com
2007-07-25 15:22 ` vda dot linux at googlemail dot com
2009-06-05 16:19 ` aldot at gcc dot gnu dot org
2009-06-06 13:41 ` hubicka at gcc dot gnu dot org
2009-06-21 16:11 ` vda dot linux at googlemail dot com
2009-06-21 16:12 ` vda dot linux at googlemail dot com
2009-06-21 16:26 ` rguenth at gcc dot gnu dot org
2009-06-21 16:47 ` vda dot linux at googlemail dot com
2009-06-21 16:48 ` vda dot linux at googlemail dot com
2009-06-30 13:36 ` hubicka at gcc dot gnu dot org
2010-01-08  9:06 ` steven at gcc dot gnu dot org
     [not found] <bug-30354-4@http.gcc.gnu.org/bugzilla/>
2012-06-28 23:29 ` aldot at gcc dot gnu.org
2013-01-18 10:29 ` vda.linux at googlemail dot com
2021-12-21 11:42 ` 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).