One embodiment of the present invention provides a system that corrects
bit errors in temporary results within a central processing unit (CPU).
During operation, the system receives a temporary result during execution
of an in-flight instruction. Next, the system generates a parity bit for
the temporary result, and stores the temporary result and the parity bit
in a temporary register within the CPU. Before the temporary result is
committed to the architectural state of the CPU, the system checks the
temporary result and the parity bit to detect a bit error. If a bit error
is detected, the system performs a micro-trap operation to re-execute the
instruction that generated the temporary result, thereby regenerating the
temporary result. Otherwise, if a bit error is not detected, the system
commits the temporary result to the architectural state of the CPU.