Reply to post: Re: "I did not know that ARM actually prohibited adding instructions"

Talk about a calculated RISC: If you think you can do a better job than Arm at designing CPUs, now's your chance

ST Silver badge

Re: "I did not know that ARM actually prohibited adding instructions"

> your OS (typically) or application determine which path is taken at runtime based on CPUID checks

No, that is not true at all. The application programmer and the compiler determine the code execution path of a program. Your application - written in a high-level language - is compiled, assembled and linked to an executable binary. The compiler + assembler generate the object files, and then the link editor glues them together into an executable. The code execution path is determined by (1) the code written and (2) the compiler. Nothing else.

I know of no compiler that arbitrarily inserts CPUID instructions at random points just to figure out where the code goes next. That's just bonkers.

CPUID will fill your registers with all kinds of values. You then have to store these values someplace. That implies stores. Where do you store them, so you can access them later? You can't keep them in registers, because these registers will be clobbered - used later on during program execution. The compiler can't invent imaginary variables to arbitrarily store the return of random CPUID instructions.

If the high-level code did not call CPUID explicitly with an assembler directive, the compiler will not hallucinate that call for you, nor will it store its results anywhere. It just doesn't happen.

> Regarding the cost of the CPUID, it is likely a one off evaluation to set variables.

No, it's not. Wikipedia for CPUID.

"Likely" does not compute. There is a known cost for the CPUID instruction - just like for every other instruction - and that cost is always the same.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon

SUBSCRIBE TO OUR WEEKLY TECH NEWSLETTER

Biting the hand that feeds IT © 1998–2019