This is the mail archive of the gcc-bugs@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]

[Bug tree-optimization/51840] asm goto incorrect code generation at -O2 and -O3


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51840

--- Comment #2 from Adam Warner <adam at consulting dot net.nz> 2012-01-13 02:08:34 UTC ---
(In reply to comment #1)
> I think the problem here is the label references are being moved which is
> correct as GCC thinks the labels where the address was taken is not going to
> happen.  I don't think you can use asm goto like this.  If you want a smaller
> indirect goto, then file a bug against GCC instead of working around it.

Bug 46219. "Generate indirect jump instruction on x86-64". Reported 2010-10-28.

If I replace the initial dispatch with a computed goto statement (leaving all
the other asm gotos alone) the code does compile correctly. It's slightly
faster but that's probably due to the asm indirect goto instructions.

There are further potential optimisation benefits in being able to specify only
the destinations of a dispatch. asm goto provides this information to the
compiler. With computed goto every dispatch is assumed to jump to every
&&label.

I've just realised this is the kind of asm goto I'm looking for:

asm goto ("jmp *%0" : : "m" (vm_dispatch[S_atop][next_inst])
 : : &&atop__a_dec, &&atop__a_non_zero_p, &&atop__exit, &&fixme);
__builtin_unreachable();

Could this bug report become a feature request for being able to specify label
addresses using labels as values "&&" syntax in asm goto statements?


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