public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: dann@godzilla.ics.uci.edu To: gcc-gnats@gcc.gnu.org Subject: optimization/5738: GCSE missed optimization Date: Wed, 20 Feb 2002 14:16:00 -0000 [thread overview] Message-ID: <20020220215216.11937.qmail@sources.redhat.com> (raw) >Number: 5738 >Category: optimization >Synopsis: GCSE missed optimization >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: pessimizes-code >Submitter-Id: net >Arrival-Date: Wed Feb 20 13:56:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: dann@godzilla.ics.uci.edu >Release: CVS >Organization: >Environment: sparc-sun-solaris2.8 >Description: GCSE not working The following code: struct foo { unsigned short *p; }; void func (struct foo *s, unsigned int *coord, _Bool delta) { unsigned short change; if (delta) { change = *((s)->p++); *coord += change; } else { change = *((s)->p++); *coord += change; *coord += *((s)->p++) << 8; } } generates when compiled with gcc from CVS on SPARC (with -O2) func: !#PROLOGUE# 0 !#PROLOGUE# 1 andcc %o2, 0xff, %g0 mov %o0, %o5 be .LL2 mov %o1, %o4 ld [%o0], %o0 ld [%o1], %o2 lduh [%o0], %o3 sll %o3, 16, %o1 srl %o1, 16, %o1 add %o2, %o1, %o2 add %o0, 2, %o0 st %o0, [%o5] b .LL1 st %o2, [%o4] .LL2: ld [%o0], %o0 lduh [%o0], %o3 ld [%o1], %o2 add %o0, 2, %o0 lduh [%o0], %o1 add %o2, %o3, %o2 sll %o1, 8, %o1 add %o2, %o1, %o2 add %o0, 2, %o0 st %o2, [%o4] st %o0, [%o5] .LL1: retl nop GCSE should be able to realize that The sequence: change = *((s)->p++); *coord += change; occurs on both branches of the conditional and move it before. >How-To-Repeat: Compile the code above with -O2 and look at the assembly, one branch of the conditional should be empty. >Fix: n/a >Release-Note: >Audit-Trail: >Unformatted:
next reply other threads:[~2002-02-20 21:56 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-02-20 14:16 dann [this message] 2002-04-03 2:25 rth 2002-04-03 5:06 Daniel Berlin 2002-04-03 5:36 Daniel Berlin 2002-04-03 10:06 Dan Nicolaescu 2002-04-03 10:55 rth 2002-04-04 8:16 law 2003-03-15 4:46 bangerth
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=20020220215216.11937.qmail@sources.redhat.com \ --to=dann@godzilla.ics.uci.edu \ --cc=gcc-gnats@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).