title: How to optimize this function with the compiler?
body: <p>I have been doing the course on Compiler and Tools (this semester). I have read till intermediate code generation and also saw DAG representation for optimality. One thing is clear with the compiler is that what ever the intermediate code have been produced, it have to be mapped to the Instruction set of the system, so that we can run our program. </p>
  
  <p>Let us say that i have a write a compiler for the particular architecture(say A),where the addition between two numbers is <strong>ADD R1,R2,R3</strong>(from the A's instruction set) where R1-is the destination,R2,R3 are the sources. And i have mapped with these instruction, that is when i want to add two numbers(regardless of its type,for simplicity) which is represented in the intermediate code, i will run the <strong>ADD</strong> opcode!. </p>
  
  <p>Assume that the new architecture have been arrived in the market, in which addition of two numbers have different Instruction set say <strong>AD R1,R2,R3</strong>. Now obviously my complier wont add the numbers! </p>
  
  <p>Now my question is when i write my compiler for the my programming language, i have to add all the architecture with their instruction set, so that my compiler does correctly what it need to do? If so what all the methods there to <strong>Optimize</strong> this effect? Because adding all the instruction set would nearly down my performance.</p>
  
  <p>Correct If I'm wrong!</p>