From: "Christian Häggström" <97nv46@skola.kiruna.se>
To: <gcc@gcc.gnu.org>
Cc: <rearnsha@arm.com>, <J.A.K.Mouw@its.tudelft.nl>
Subject: Re: Volatile constants?
Date: Mon, 03 Apr 2000 02:33:00 -0000 [thread overview]
Message-ID: <s8e8815a.075@ymer> (raw)
> Because even in C++ you have still specified it as a constructor function,
> not a constant expression.
Is there any way to optimize away constant constructors?
Otherwise, an new option to manage this have been nice.
---
I have another example of GCC's silly constant handling
assume we have an array like this
int regs[8];
and we want to access 'regs[3]' as 'ebx'
( best viewed with fixed size font )
method 1 const pointer | method 2 const reference
---------------------- | ------------------------
// definitions //
typedef int * intp; | typedef int & intref;
const intp ebx = regs+3; | const intref ebx = regs[3];
// access example //
void set_ebx(int val) { | void set_ebx(int val) {
*ebx = val; | ebx = val;
} | }
// asm output (i386,regparm) //
set_ebx: | set_ebx:
movl %eax,regs+12 | movl %eax,%edx
| movl ebx,%eax
| movl %edx,(%eax)
ret | ret
| .section .rodata
| ebx:
| .long regs+12
I want to use method 2 because it is cleaner, but do I get different output?
next reply other threads:[~2000-04-03 2:33 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-04-03 2:33 Christian Häggström [this message]
[not found] <s8e49edd.056@ymer>
2000-03-31 3:17 ` Richard Earnshaw
-- strict thread matches above, loose matches on Subject: below --
2000-03-31 2:50 Christian Häggström
2000-03-29 23:31 Christian Häggström
2000-03-30 4:21 ` Richard Earnshaw
2000-03-29 4:57 Christian Häggström
2000-03-29 7:41 ` Erik Mouw
2000-03-29 9:53 ` Alasdair Baird
2000-03-29 10:05 ` Erik Mouw
2000-03-29 7:45 ` Kevin Handy
2000-03-29 12:18 ` Andi Kleen
2000-02-22 0:52 Christian Häggström
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=s8e8815a.075@ymer \
--to=97nv46@skola.kiruna.se \
--cc=J.A.K.Mouw@its.tudelft.nl \
--cc=gcc@gcc.gnu.org \
--cc=rearnsha@arm.com \
/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).