Lec 11 · Branch target·return stack·LSQ 와 VLIW 도입
정밀 정리 · 검증 2026-09-24 02:16
1개요
1.1ca_L08 후반: BTB·BHT 결합, JR 과 return address stack, in-order/OoO mispredict recovery(mask bit, rename snapshot).
1.2fetch bandwidth: Alpha 21264 line/way prediction·tournament predictor, branch address cache, trace cache.
1.3memory: speculative store buffer, load bypass, in-order queue → conservative OoO load → address speculation.
1.4ca_L09 도입: OoO control logic ∝ W×(W×L), sequential ISA 의 정보 손실, VLIW 의 slot 구조(p1-5).
2섹션별 정리 상황·문제 → 원인 → 해결
2.10:46–6:50BHT 한계 → BTB, 그리고 BTB·BHT 결합
상황·문제BHT 는 방향만 예측해 taken 이어도 target 이 계산될 때까지 fetch 를 redirect 못 한다.
원인target 은 decode 후에 나오고, JR 처럼 register 를 읽어야 하면 penalty 가 더 크다 (UltraSPARC-III fetch pipeline).
해결BTB: PC 로 index, entry PC 비교·valid 면 target 으로, 아니면 PC+4. BTB 는 앞단에서 redirect, 뒤의 BHT 가 BTB miss 를 교정.
- BTB 에는 taken branch·jump 만 저장
- BTB 는 BHT 보다 비싸지만 앞 stage 에서 redirect·JR 가속
- BHT 는 entry 가 많아 더 정확, 둘 다 E stage 에서 resolve 후 갱신
2.26:50–10:00Jump register(JR) 의 용도와 BTB 적합성
상황·문제JR(indirect jump)은 switch, 동적 함수 호출(C++ virtual function), subroutine return 에 쓰인다.
원인target 이 register 값이라 매번 바뀔 수 있다. 여러 곳에서 호출되는 함수의 return 은 BTB 로 맞히기 어렵다.
해결switch·동적 호출은 같은 case·함수가 반복되면 BTB 가 잘 맞는다. return 은 별도 구조가 필요.
- 함수 호출은 매우 빈번 → return 전용 가속이 가치 있음
2.2.r.1Branch predictor — Wikipedia ↗ · hybrid(tournament) predictor, indirect branch predictor, return stack buffer 절
2.310:00–15:48Subroutine return stack 과 pipeline 통합
상황·문제fa→fb→fc→fd 처럼 중첩 호출 후 차례로 return 한다.
원인call/return 여부는 decode 에서야 알 수 있어, decode 후 push/pop 하면 fetch stream 에 큰 bubble.
해결call 때 호출 주소 push, return 때 pop (k=8-16). BTB 비슷한 구조에 target 대신 push/pop bit 만 두어 decode 전에 수행, 나중에 확인.
- BTB 보다 훨씬 정확한 return 예측
- target 은 계속 바뀌므로 저장하지 않고 stack 에서 얻음
2.3.r.1Branch predictor — Wikipedia ↗ · hybrid(tournament) predictor, indirect branch predictor, return stack buffer 절
2.415:48–20:17In-order vs OoO 의 branch prediction 과 mispredict recovery
상황·문제in-order 는 speculative fetch 만, OoO 는 branch 뒤 명령어를 speculative execute 해 branch 보다 먼저 완료할 수 있다.
원인완료 값은 in-order 는 bypass network, OoO 는 ROB 나 unified PRF 에 commit 전까지 보관된다.
해결in-order: branch resolve 전 write-back 금지 후 뒤를 kill. OoO: 뒤 명령어 효과를 되돌려야 하며 precise trap 방식은 naive 한 방법.
- 두 방식 모두 같은 front-end predictor 사용
- OoO 는 wrong path 실행이 많아 더 정확한 predictor 필요
2.4.r.1Branch predictor — Wikipedia ↗ · hybrid(tournament) predictor, indirect branch predictor, return stack buffer 절
2.520:17–28:09여러 미해결 branch: mask bit 와 rename table snapshot
상황·문제ROB 에 unresolved branch 가 여럿 있고 branch 자체도 out-of-order 로 resolve 된다.
원인branch 는 execute stage(mid-pipeline)에서 resolve 되어, trap 처럼 commit 에서 전부 flush 할 수 없다. 앞 명령어는 계속 실행돼야 한다.
해결R10K: 4 mask bit 로 최대 4개 speculative branch 의존 명령어 표시, branch 별 rename snapshot 4개. Alpha 21264: ROB 명령어당 1개, snapshot 80개.
- mispredict 된 branch 뒤 명령어만 kill
- rename table 은 최신·최초가 아닌 중간 상태로 복구해야 함
- mask bit 는 resolve 후 clear, 다음 branch 에 재사용
2.5.r.1Yeager, The MIPS R10000 Superscalar Microprocessor (IEEE Micro 1996) ↗ · 4-bit branch mask·branch stack, address queue 로 memory dependence 판단
2.628:09–33:40Instruction fetch 개선: Alpha 21264 line/way prediction
상황·문제speculative OoO 성능은 fetch bandwidth 에 자주 제한된다. commit 보다 2-3배 많이 fetch 할 수 있다.
원인mispredict penalty 는 instruction window 재충전 시간이 좌우하고, taken branch 는 fetch 흐름을 끊는다.
해결21264 I-cache 가 명령어마다 next line·way 를 예측(BTB 역할)해 tag check·decode·branch prediction 을 critical loop 밖으로. 2-bit hysteresis 로 overtraining 방지.
- 2-way set associative I-cache 에 line predict·way predict field
- fetch unit 은 이 예측 대신 PC+4 나 branch predictor 결과를 택할 수 있음
2.6.r.1Kessler, The Alpha 21264 Microprocessor (IEEE Micro 1999) — UPenn CIS501 사본 ↗ · line/way prediction, tournament predictor(Fig 4), store wait table 로 load speculation 학습
2.733:40–35:52Alpha 21264 tournament predictor
상황·문제branch 마다 local pattern 이 맞는 것과 global correlation 이 맞는 것이 다르다.
원인한 종류 predictor 로는 다양한 branch 행동을 다 잡지 못한다.
해결local(PC→local history table→local prediction)과 global(12-bit global history) 예측을 따로 하고 choice predictor 가 선택.
- global predictor 는 PC 를 쓰지 않음
- 논문은 다양한 응용에서 90-100% 성공 주장
2.7.r.1Kessler, The Alpha 21264 Microprocessor (IEEE Micro 1999) — UPenn CIS501 사본 ↗ · line/way prediction, tournament predictor(Fig 4), store wait table 로 load speculation 학습
2.7.r.2Branch predictor — Wikipedia ↗ · hybrid(tournament) predictor, indirect branch predictor, return stack buffer 절
2.835:52–42:45Cycle 당 여러 taken branch: branch address cache 와 trace cache
상황·문제integer code 는 6-9 명령어마다 taken branch, basic block 이 짧고 control flow 가 불규칙하다.
원인cycle 당 여러 branch 예측과 비연속 block fetch 가 필요. multi-port cache 는 비싸고 banking 은 bank conflict.
해결branch address cache: BTB entry 에 target 여러 개. trace cache: 비연속 basic block 을 한 line 에 pack, 시작 PC + 다음 n 개 prediction 으로 index.
- 같은 시작 주소라도 예측 경로별로 다른 trace line
- Pentium 4 trace cache 는 12K decoded micro-op 저장
2.8.r.1Trace cache — Wikipedia ↗ · 시작 PC + branch prediction 으로 trace line 저장, Pentium 4 execution trace cache
2.942:45–49:15Load-store queue: speculative store buffer 와 load bypass
상황·문제control hazard 다음 병목은 memory 를 통한 data hazard. register 는 RS·ROB·renaming 으로 해결했지만 memory 는 아직.
원인store 는 commit 전 memory 를 바꾸면 안 되므로 address·data 를 buffer 에 보관해야 한다.
해결decode 때 program order 로 slot 할당, oldest 가 되면 L1 D-cache 로 commit, abort 시 valid clear. load 는 store buffer 와 cache 둘 다 있으면 buffer, 여럿이면 load 보다 오래된 것 중 최신.
- store 는 store address / store data uop 로 분리
- load 보다 younger 인 store entry 는 무시
2.9.r.1Memory disambiguation — Wikipedia ↗ · store queue, store-to-load forwarding, memory dependence prediction
2.1049:15–56:25Memory dependence: in-order memory queue 와 conservative OoO load
상황·문제sd x1,(x2) 뒤 ld x3,(x4): store 주소를 모르는데 load 주소는 알 때 load 를 언제 실행하나.
원인x4 == x2 면 load 가 store 값을 읽어야 하므로 순서를 어기면 program semantics 위반.
해결in-order queue: 이전 load/store 완료까지 대기(다른 명령어와는 OoO). conservative: 주소가 알려지고 x4 != x2 면 load 먼저, 미확정 store 가 있으면 대기.
- load 주소를 모든 이전 uncommitted store 와 비교, 하위 12bit 부분 비교로 hardware 절약
- load 가 store 보다 성능에 중요
- MIPS R10K 16-entry address queue
2.10.r.1Memory disambiguation — Wikipedia ↗ · store queue, store-to-load forwarding, memory dependence prediction
2.10.r.2Yeager, The MIPS R10000 Superscalar Microprocessor (IEEE Micro 1996) ↗ · 4-bit branch mask·branch stack, address queue 로 memory dependence 판단
2.1156:25–1:02:16Address speculation (Alpha 21264) 과 Q&A
상황·문제conservative 방식은 대부분 주소가 달라도 기다려 성능을 잃는다.
원인x4 != x2 로 추측해 store 주소 전에 load 실행, 나중에 x4 == x2 면 load 와 이후 명령어 squash.
해결squash 된 load 는 store-wait bit 로 이후 실행 시 이전 store 완료까지 대기, 주기적으로 clear. 틀리면 penalty 가 커서 conservative 보다 나빠질 수도.
- 완료했지만 uncommitted 인 load/store 주소를 program order 로 보관
- Q&A: branch speculation 중 store 는 store buffer 에만 있어 mispredict 시 entry flush 로 되돌림
2.11.r.1Kessler, The Alpha 21264 Microprocessor (IEEE Micro 1999) — UPenn CIS501 사본 ↗ · line/way prediction, tournament predictor(Fig 4), store wait table 로 load speculation 학습
2.11.r.2Memory disambiguation — Wikipedia ↗ · store queue, store-to-load forwarding, memory dependence prediction
2.121:02:16–1:08:38Lec 9 VLIW 도입: superscalar control logic scaling
상황·문제issue width W, instruction lifetime L 이면 새 명령어마다 W×L 개와 dependence check → hardware ∝ W×(W×L).
원인OoO 는 L 에 instruction buffer·ROB 대기 시간까지 포함, W 를 늘리면 window 도 커져 L 증가.
해결OoO control logic 은 W² 보다 빠르게(~W³) 증가. MIPS R10000 die 에서 control logic 면적이 크다. 이 overhead 를 datapath·cache 로 돌리고 싶다.
- in-order 는 issue 때 interlock/scoreboard 로 check
- OoO 는 write back 때 tag broadcast 로 대기 명령어와 비교
2.12.r.1Very long instruction word — Wikipedia ↗ · 병렬성 탐색을 hardware 에서 compiler 로, Multiflow·Cydrome·Itanium
2.131:08:38–1:12:21Sequential ISA bottleneck 과 VLIW 개념, 보강 공지
상황·문제compiler 는 연산 간 독립성을 알지만 sequential machine code 로 내리며 그 정보를 잃는다.
원인processor 는 register 이름만으로 dependence 를 다시 찾고 다시 schedule 한다.
해결VLIW: 한 instruction 에 연산 6개(Int 2·Mem 2·FP 2), slot 별 고정 기능·고정 latency, dependence 는 compiler 가 보장해 hardware 단순화.
- Int 1-cycle, Load/Store 3-cycle, FP 4-cycle latency
- 휴일 보강 수업을 따로 공지할 예정
2.13.r.1Very long instruction word — Wikipedia ↗ · 병렬성 탐색을 hardware 에서 compiler 로, Multiflow·Cydrome·Itanium
3핵심 개념
3.1BTB, branch target buffer(분기 타겟 버퍼)
PC 로 index 해 entry PC 가 맞으면 저장된 target 으로 fetch, 아니면 PC+4. taken branch·jump 만 저장.
3.2return address stack(리턴 주소 스택)
call 때 호출 주소 push, return 때 pop. k=8-16 entry, return JR 을 BTB 보다 정확히 예측.
3.2.r.1Branch predictor — Wikipedia ↗ · hybrid(tournament) predictor, indirect branch predictor, return stack buffer 절
3.3branch mask(브랜치 마스크)
R10K 는 4 bit 로 명령어가 어느 speculative branch 에 의존하는지 표시, mispredict 시 해당 명령어만 kill.
3.3.r.1Yeager, The MIPS R10000 Superscalar Microprocessor (IEEE Micro 1996) ↗ · 4-bit branch mask·branch stack, address queue 로 memory dependence 판단
3.4tournament predictor(토너먼트 예측기)
local·global predictor 를 함께 두고 choice(meta) predictor 가 branch 별로 선택.
3.4.r.1Kessler, The Alpha 21264 Microprocessor (IEEE Micro 1999) — UPenn CIS501 사본 ↗ · line/way prediction, tournament predictor(Fig 4), store wait table 로 load speculation 학습
3.5trace cache(트레이스 캐시)
비연속 basic block 을 한 line 에 저장, 시작 PC + 다음 n 개 branch prediction 으로 index.
3.5.r.1Trace cache — Wikipedia ↗ · 시작 PC + branch prediction 으로 trace line 저장, Pentium 4 execution trace cache
3.6speculative store buffer(추측 store 버퍼)
commit 전 store 의 address·data 보관. oldest 가 되면 cache 로 쓰고, abort 시 valid clear.
3.6.r.1Memory disambiguation — Wikipedia ↗ · store queue, store-to-load forwarding, memory dependence prediction
3.7address speculation(주소 추측)
store 주소를 모를 때 다르다고 가정해 load 를 먼저 실행, 겹치면 squash 후 store-wait bit 로 대기.
3.7.r.1Kessler, The Alpha 21264 Microprocessor (IEEE Micro 1999) — UPenn CIS501 사본 ↗ · line/way prediction, tournament predictor(Fig 4), store wait table 로 load speculation 학습
3.8VLIW, very long instruction word
compiler 가 독립 연산을 한 instruction 의 고정 slot 에 묶어 hardware dependence check 를 없앰.
3.8.r.1Very long instruction word — Wikipedia ↗ · 병렬성 탐색을 hardware 에서 compiler 로, Multiflow·Cydrome·Itanium
4스스로 확인
4.1BTB 가 BHT 보다 앞 stage 에서 쓸 수 있는 이유는?
답
decode 없이 PC 만으로 entry PC 를 비교해 target 을 얻기 때문. 대신 entry 가 비싸 수가 적다.
4.2return stack 을 decode 전에 push/pop 하려면 무엇을 저장하나?
답
BTB 같은 구조에 target 대신 push/pop bit 만 저장하고 주소는 stack 에서 얻는다.
4.3branch mispredict recovery 가 trap recovery 와 다른 점은?
답
branch 는 execute(mid-pipeline)에서 resolve 되어, 앞 명령어는 살리고 뒤 명령어만 kill 해야 한다.
4.4store buffer 에 같은 주소 store 가 둘이면 load 는 어느 값을 쓰나?
답
load 보다 오래된 store 중 가장 최근 것. load 보다 younger 인 store 는 무시.
4.5address speculation 이 conservative OoO 보다 나쁠 수 있는 경우는?
답
x4==x2 로 추측이 자주 틀리면 load 와 이후 명령어를 squash 하는 penalty 가 커진다.
4.6OoO dependence check hardware 가 W 에 대해 W² 보다 빨리 커지는 이유는?
답
W×(W×L) 에서 W 를 늘리면 window 가 커져 L 도 늘기 때문(~W³).
5참고 자료
5.1Computer Architecture: A Quantitative Approach, 6th ed. — Elsevier ↗ · 교재. ca_L08 권장 3.9-3.10, ca_L09 권장 3.7·Appendix H(VLIW/EPIC)
5.2Branch predictor — Wikipedia ↗ · hybrid(tournament) predictor, indirect branch predictor, return stack buffer 절
5.3Kessler, The Alpha 21264 Microprocessor (IEEE Micro 1999) — UPenn CIS501 사본 ↗ · line/way prediction, tournament predictor(Fig 4), store wait table 로 load speculation 학습
5.4Yeager, The MIPS R10000 Superscalar Microprocessor (IEEE Micro 1996) ↗ · 4-bit branch mask·branch stack, address queue 로 memory dependence 판단
5.5Memory disambiguation — Wikipedia ↗ · store queue, store-to-load forwarding, memory dependence prediction
5.6Very long instruction word — Wikipedia ↗ · 병렬성 탐색을 hardware 에서 compiler 로, Multiflow·Cydrome·Itanium





























