public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "mkuvyrkov at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/42574] [4.3/4.4/4.5/4.6 Regression] Address of global variable is calculated multiple times (missed CSE) Date: Tue, 08 Jun 2010 15:24:00 -0000 [thread overview] Message-ID: <20100608152426.21263.qmail@sourceware.org> (raw) In-Reply-To: <bug-42574-17572@http.gcc.gnu.org/bugzilla/> ------- Comment #10 from mkuvyrkov at gcc dot gnu dot org 2010-06-08 15:24 ------- Steven, I'm shamelessly stealing this PR from you. There are two sides to this missed optimization: 1. Calculation of PIC address is not CSE'd; this is the same as PR42495 and will be fixed there. 2. Constant "400", which expands to 2 instructions is not CSE'd. After addressing the first issue, the second problem can be fixed by asking hoist to CSE "complicated" constants and making sure that RA will rematerialize them instead of spilling under high register pressure. We can define a constant "complicated" if it takes a PARALLEL -- (parallel [(set (reg1) (const)) (clobber reg2)]) -- to set it; this is a common way of defining instructions that should be split later and require a temporary register to hold intermediate value. I'm now testing a patch that makes ARM backend to expand constants into parallels instead of sequences of two instructions and tweaking hoist to gcse "complicated" const_int's. The result is the following: test: push {r4, r5, r6, lr} ldr r3, .L3 ldr r2, .L3+4 .LPIC0: add r3, pc ldr r5, [r3, r2] mov r4, #200 lsl r4, r4, #1 mov r6, r0 ldr r0, [r5, r4] bl func1 ldr r0, [r5, r4] mov r1, r6 bl func2 cmp r0, #0 beq .L2 bl func .L2: ldr r0, [r5, r4] bl func3 @ sp needed for prologue pop {r4, r5, r6, pc} .L4: .align 2 .L3: .word _GLOBAL_OFFSET_TABLE_-(.LPIC0+4) .word glob(GOT) -- mkuvyrkov at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|steven at gcc dot gnu dot |mkuvyrkov at gcc dot gnu dot |org |org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42574
next prev parent reply other threads:[~2010-06-08 15:24 UTC|newest] Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top 2010-01-01 17:28 [Bug middle-end/42574] New: Address of global variable is calculated multiple times; CSE doesn't work properly sliao at google dot com 2010-01-01 20:16 ` [Bug middle-end/42574] " steven at gcc dot gnu dot org 2010-01-01 20:35 ` [Bug middle-end/42574] [4.3/4.4/4.5 Regression] Address of global variable is calculated multiple times (missed CSE) steven at gcc dot gnu dot org 2010-01-01 20:36 ` rguenth at gcc dot gnu dot org 2010-01-01 20:39 ` rguenth at gcc dot gnu dot org 2010-01-01 20:44 ` steven at gcc dot gnu dot org 2010-01-01 21:00 ` steven at gcc dot gnu dot org 2010-01-02 0:12 ` steven at gcc dot gnu dot org 2010-01-02 14:08 ` steven at gcc dot gnu dot org 2010-01-02 14:08 ` steven at gcc dot gnu dot org 2010-01-02 14:10 ` steven at gcc dot gnu dot org 2010-01-02 16:17 ` rguenth at gcc dot gnu dot org 2010-02-08 12:15 ` steven at gcc dot gnu dot org 2010-04-14 20:50 ` [Bug middle-end/42574] [4.3/4.4/4.5/4.6 " steven at gcc dot gnu dot org 2010-05-22 18:34 ` rguenth at gcc dot gnu dot org 2010-06-08 15:24 ` mkuvyrkov at gcc dot gnu dot org [this message] 2010-07-27 19:35 ` mkuvyrkov at gcc dot gnu dot org 2010-07-27 19:38 ` mkuvyrkov at gcc dot gnu dot org 2010-07-27 19:42 ` mkuvyrkov at gcc dot gnu dot org 2010-07-27 19:45 ` mkuvyrkov at gcc dot gnu dot org 2010-07-27 19:48 ` mkuvyrkov at gcc dot gnu dot org 2010-07-27 21:07 ` mkuvyrkov at gcc dot gnu dot org 2010-07-27 21:11 ` mkuvyrkov at gcc dot gnu dot org
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=20100608152426.21263.qmail@sourceware.org \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@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: linkBe 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).