This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH, i386]: Emit cld instruction when stringops are used
Chris Lattner wrote:
This patch adds back generation of cld instructions when stringops are
used in the function. cld insn is emitted as unspec volatile at the
end of function prologue. Currently, patched gcc emits cld when
"-mcld" is added to compile flags.
Currently, there is no configure-time support, I think we should first
reach a consensus on how to configure this. We can
If I understand the issue correctly, this patch is insufficient. You
should also have GCC emit a cld instruction before any inline asm. Do
you think it's a good idea to add a 52 cycle delay (on the P4) to any
function that uses inline asm?
No, this patch in effect restores previous functionality for what is
considered buggy code (in the sense that doesn't follow psABI w.r.t. to
direction flag). This patch should be treated as a band-aid for corner
cases, nothing less and nothing more. In previous versions, inline asm
was not handled at all and all [asm] code was written with this fact in
Due to this, IMO there is no point to implement cld inserting via LCM
(this would require major work, since we will have to restore REG_DIR
fake register in order to make _all_ stringop patterns consumers of this
register). There is also no point to trigger cld insertion with inline
asm, as this will fix a non-bug.
IMO, -mcld should be off by default. This flag should provide a way to
still compile the code that is now _known_ to be buggy. But it is up to
distributions to decide if they want to penalize applications with
unnecessary cld instructions. I expect that the need for -mcld will
phase out relatively quickly.