Compiler design for GATE is highly scoring if you master:
Follow the Gate Smashers mantra: “Concepts clear karo, bas phir GATE crack hai” (Clear your concepts, and GATE is cracked).
To understand "Gate Smashing," we first have to understand why branches are problematic.
Modern CPUs are not just calculators; they are assembly lines. They use instruction pipelining to fetch, decode, and execute multiple instructions simultaneously. To keep this assembly line moving, the CPU uses Branch Prediction. It looks at a conditional jump (a gate) and makes an educated guess: "Last time we were here, we went left, so let’s pre-load instructions from the left."
The Cost of a Misprediction: When the predictor is right, the program runs smoothly. When it is wrong, the CPU realizes the mistake late in the pipeline. It must:
On modern architectures, a single branch misprediction can cost 10 to 20 clock cycles. In tight loops (like rendering graphics or processing network packets), this adds up to massive delays.
The "Gate Smasher" Philosophy: Instead of relying on the hardware to guess correctly, the compiler attempts to remove the gate entirely. The goal is to convert control dependencies (branching) into data dependencies (calculations).
Strategy: Practice transforming grammars, hand-simulate parsers, and solve peephole/codegen problems.
This phase improves the efficiency of the code.