This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: equality of label addresses


On Wed, Jan 29, 2003 at 03:07:38PM +1100, Fergus Henderson wrote:
> The program below works fine with `-O0', but gets an assertion failure
> with `-O2', because with `-00', the two labels `label2' and `label3'
> have different addresses, but with `-O2', GCC does some duplicate code
> elimination and so the two labels end up pointing to the same code.
> (This is with gcc 2.95 and 3.1.  I haven't tested this with
> the current mainline.)
> Is this a valid optimization?

IMO yes.  If you goto that label, do you not get correct results?

> Even more worrying is that GCC 3.1 will do the same optimization
> even if you insert ` asm volatile("nop"); ' in front of each
> call to foo() -- the generated code contains only a single "nop"
> instruction.  This seems to contradict the GCC documentation,
> which says that volatile asm instructions will not be
> "deleted, moved significantly, or combined".
> Is this a bug?

Unless I'm misunderstanding you, we did not combine two dynamic
invocations of the asm.  Instead we combined two instances of
the asm seen on different execution paths.  Thus the sequence
of instructions seen at runtime are identical.

Thus I believe this optimization to be valid as well.

> If not, then I think the documentation for volatile asm instructions
> should be clarified.

Care to write the patch?


r~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]