lec17 - LECTURE - 17 LECTURE - 17 Speculation Wish to move...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: LECTURE - 17 LECTURE - 17 Speculation Wish to move instructions across branches To eliminate possible stalls For better scheduling Appropriate conditional instructions may not always exist Example: if (N == 0) { A = *X; } else { A++; } Speculation: An Example Compiler predicts that the “ the n” clause is most likely Speculatively schedules the “ th en” clause Eliminates 2 stalls, and the JMP instruction LW R1, 0(R2) // Load N BNEZ R1, L1 // Test N LW R3, 0(R4) // Load X LW R5, 0(R3) // Load *X JMP L2 // Skip else L1: LW R5, 0(R6) // Load A ADDI R5, R5, #1 // Incrmt. L2: SW 0(R6), R3 // Store A LW R1, 0(R2) // Load N LW R3, 0(R4) // Load X LW R5, 0(R3) // Load *X BEQZ R1, L3 // Test N LW R5, 0(R6) // Load A ADDI R5, R5, #1 // Incrmt. L2: SW 0(R6), R5 // Store A Exception Behaviour Terminating vs. non-terminating exceptions While doing such scheduling: Correct program ==> no extra terminating exceptions Incorrect program ==> should preserve any terminating exceptions LW R1, 0(R2) // Load N LW R3, 0(R4) // Load X LW R5, 0(R3) // Load *X BEQZ R1, L3 // Test N LW R5, 0(R6) // Load A ADDI R5, R5, #1 // Incrmt. L2: SW 0(R6), R5 // Store A Preserving Exception Behaviour Approach 1: ignore terminating exceptions for speculated instructions Incorrect programs may not be terminated LW R1, 0(R2) // Load N LW* R3, 0(R4) // Load X, speculated LW* R5, 0(R3) // Load *X, speculated BEQZ R1, L3 // Test N LW R5, 0(R6) // Load A ADDI R5, R5, #1 // Incrmt....
View Full Document

This note was uploaded on 07/14/2011 for the course CS 422 taught by Professor Hogakoi during the Spring '10 term at IIT Kanpur.

Page1 / 23

lec17 - LECTURE - 17 LECTURE - 17 Speculation Wish to move...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online