Professional Documents
Culture Documents
CMOVZ R2,R3, R1
L:
Conditional loads and stores
ALPHA, MIPS, SPARC, PowerPC, and P6 all have simple
conditional moves
IA_64 supports full predication for all instructions
BEQZ R10, L
LW R8, 20(R10)
LW R9, 0(R8)
First slot(Mem)
LW R1,40(R2)
Limits
Speculated values cant clobber any real results
Exceptions can not cause any destructive activity
6
To Speculate Ambitiously
Ability of the compiler to find instructions that
can be speculatively moved and not affect the
program data flow
Ability of HW to ignore exceptions in
speculated instructions, until we know that
such exceptions should really occur
Ability of HW to speculatively interchange
loads and stores, or stores and stores, which
may have address conflicts
7
Exception Types
Indicate a program error and normally cause
termination
Memory protection violation
Should not be handled for SI when misprediction
Exceptions cannot be taken until we know the
instruction is no longer speculative
10
L1: DADDI
L2: SD
Compiler-based speculation
LD
R1, 0(R3) ; load A
LD R14, 0(R2) ;spec-lw B
BEQZ
R1, L3
; other
bran.
DADDI
L3: SD
11
Non-Terminating Speculative
Instructions + Exception Checking
LD
sLD
BNEZ
SPECCK
J
L1: DADDI
L2: SD
L2
R14, R1, #4 ;else
R14,0(R3) ; store A
12
Poison Bits
Track exceptions as they occur but postpones
any terminating exception until a value is
actually used.
Incorrect programs that caused termination
without speculation will still cause exceptions
when instructions are speculated.
Poison bit for every register. A bit to indicate SI
The poison bit of a destination register is set
when SI results in a terminating exception.
All other exceptions are handled immediately
13
Poison-Bit Example
LD
R1, 0(R3) ; load A
sLD
R14, 0(R2) ; spec-lw B. If exception
R14 poisoned
BEQZ
R1, L3
; other bran.
DADDI
L3: SD
R14, R1, #4
; else
R14, 0(R3) ; store A. R14 poisoned SD fault
14
Boosting
Boosting
How to deal with exception? Similar to Poison Bits?
Reduce # of registers used
Provide separate shadow resources for boosted
instruction results
If condition resolves selecting the boosted path
Then these results are committed to the real registers
LD
R1, 0(R3) ; load A
LD+
R1, 0(R2) ; Boosted load B. Result is
never written to
; R1 if
branch is not taken
15
16
17
18
19
20
HW Versus SW Speculation
Mechanisms (Cont.)
HW speculation with dynamic scheduling does
not require different code sequences to
achieve good performance for different
implementation of an architecture
HW speculation require complex and
additional HW resources
Some designers have tried to combine the
dynamic and compiler-based approaches to
achieve the best of each
21