How do compilers use IR?

Compilers translate the source code of a program to an intermediate representation (IR), which is a form more suitable for performing code transformations before generating object code for the target machine.