Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • On x86 ABI, ebx, ebp, esi, and edi are required to be saved by the callee if it clobbers them. This is correct. The problem is that gcc unconditionally does all the work of saving and restoring them at function entry and exit, even when the simple case never clobbers them. If it moved the saving and restoring inside the complex branch, the simple branch would be half (or fewer) as many instructions and significantly faster. Commented Mar 30, 2011 at 12:32
  • @R..: You can tweak that behavior a bit but there isn't much fine grained control — and if these functions are extern and not under your control, how do you know there are unused registers? Commented Mar 30, 2011 at 17:22
  • @geekosaur: This question has nothing to do with code generation for the caller, which of course cannot know what registers the callee uses. This whole topic is about code generation for the callee, which absolutely knows what registers it uses. Commented Mar 30, 2011 at 18:23
  • No, it only absolutely knows if you write it in assembler or you insist on a particular compiler version and optimization level so that you know with certainty the generated code. In any case, I'm done with this question; you're clearly stuck in a world view in which the only possible answer is "you can't". Commented Mar 30, 2011 at 18:27
  • And you're clearly only interested in giving me "advice" along the lines of "throw other much-more-important considerations out the window and do what I say" rather than trying to answer the question. Commented Mar 30, 2011 at 18:33