public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Fariborz Jahanian <fjahanian@apple.com>
To: gcc@gcc.gnu.org
Subject: [RFH] - Less than optimal code compiling 252.eon -O2 for x86
Date: Fri, 24 Jun 2005 22:06:00 -0000	[thread overview]
Message-ID: <B7C12C01-DBA8-4F56-9DF3-4BE0C45D5ADD@apple.com> (raw)

A source file mrSurfaceList.cc of 252.eon produces less efficient  
code initializing instance objects to 0 at -O2 than at -O1. Behavior  
is random and it does not happen on all x86  platforms and making the  
test smaller makes the problem go away. But here is what I found out  
is the cause.

When source is compiled with -O1 -march=pentium4,  'cse' phase sees  
the following pattern initializing a 'double' with 0.

(insn 18 13 19 0 (set (reg:SF 109)
         (mem/u/i:SF (symbol_ref/u:SI ("*LC11") [flags 0x2]) [0 S4  
A32])) -1 (nil)
     (nil))

(insn 19 18 20 0 (set (mem/s/j:DF (plus:SI (reg/f:SI 20 frame)
                 (const_int -32 [0xffffffffffffffe0])) [0  
objectBox.pmin.e+16 S8 A128])
         (float_extend:DF (reg:SF 109))) 86 {*extendsfdf2_sse} (nil)
     (nil))

Then fold_rtx routine  converts it into its reduced form, resulting  
in optimum code:

(insn 19 13 21 0 (set (mem/s/j:DF (plus:SI (reg/f:SI 20 frame)
                 (const_int -32 [0xffffffffffffffe0])) [0  
objectBox.pmin.e+16 S8 A128])
         (const_double:DF 0.0 [0x0.0p+0])) 64 {*movdf_nointeger} (nil)
     (nil))


But when the same source is compiled with -O2 march=pentium4, 'cse'  
phase sees a slightly different pattern (note that float_extend:DF  
has moved)

(insn 18 13 19 0 (set (reg:DF 109)
         (float_extend:DF (mem/u/i:SF (symbol_ref/u:SI ("*LC13")  
[flags 0x2]) [0 S4 A32]))) -1 (nil)
     (nil))

(insn 19 18 20 0 (set (mem/s/j:DF (plus:SI (reg/f:SI 20 frame)
                 (const_int -32 [0xffffffffffffffe0])) [0  
objectBox.pmin.e+16 S8 A128])
         (reg:DF 109)) 64 {*movdf_nointeger} (nil)
     (nil))

This cannot be simplified by fold_rtx, resulting in less efficient code.

Change in pattern is most likely because of additional tree  
optimization phases running at -O2. If so, then should the cse be  
taught to simplify the new rtl pattern. Or, the tree optimizer phase  
responsible for the less than optimal tree need be twiked to generate  
the same tree as with -O1?

Thanks, fariborz

             reply	other threads:[~2005-06-24 22:06 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-24 22:06 Fariborz Jahanian [this message]
2005-06-24 22:17 ` Andrew Pinski
2005-06-24 23:46   ` fjahanian
2005-06-25  0:06     ` Steven Bosscher
2005-06-30 14:42       ` fjahanian
2005-06-30 15:03         ` fjahanian
2005-06-27 19:20 ` Fariborz Jahanian
2005-06-27 19:56   ` Richard Henderson
2005-06-27 21:52     ` Fariborz Jahanian
2005-06-30 16:04       ` fjahanian
2005-06-30 16:08         ` Andrew Pinski
2005-06-30 16:55         ` Steven Bosscher
2005-06-30 17:48           ` Jeffrey A Law
2005-06-30 18:12             ` Bernd Schmidt
2005-06-30 18:19               ` Joe Buck
2005-06-30 18:25                 ` Giovanni Bajo
2005-06-30 18:23               ` Jeffrey A Law
2005-06-30 19:06                 ` Fariborz Jahanian
2005-06-30 19:47                   ` Steven Bosscher
2005-06-30 21:30                     ` Fariborz Jahanian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=B7C12C01-DBA8-4F56-9DF3-4BE0C45D5ADD@apple.com \
    --to=fjahanian@apple.com \
    --cc=gcc@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).