主权项 |
1. A method for predicting a branch in an instruction stream, the method comprising:
receiving, by a processor, a first instruction within a first instruction stream, wherein the first instruction includes at least a first instruction address; selecting, by the processor, a current row of a branch target buffer and a corresponding current row of a one-dimensional array based, at least in part, on the first instruction address; reading, by the processor, information included in the current row of the one-dimensional array, wherein the current row of one-dimensional array includes at least a first target address of a first prediction and a column of the current row of the branch target buffer expected to contain a second target address of a second prediction, wherein each prediction comprises an expected address, within the first instruction stream, of a taken branch and a target address of the taken branch; receiving, by the processor, a second instruction within a second instruction stream, wherein the second instruction includes a second instruction address and the second instruction address is equal to the first target address, and wherein the second instruction stream comprises at least a portion of the first instruction stream; reading, by the processor, information included in the current row of the branch target buffer, wherein the information included in at least one column of the current row of the branch target buffer includes at least the second target address of the second prediction; determining, by the processor, that the first target address differs from the second target address based, at least in part, on the information read from the current row of the branch target buffer and the information read from the current row of the one-dimensional array; updating, by the processor, the information included in the current row of the one-dimensional array to include the second target address of the second prediction and the at least one column of the current row of the branch target buffer that includes at least the second target address of the second prediction; encountering, by the processor, a branch present within the first instruction stream, wherein the encountered branch includes at least a third target address; determining, by the processor, that the first target address is equivalent to the second target address and differs from the third target address based, at least in part, on the information read from the current row of the one-dimensional array and the branch encountered within the first instruction stream; updating, by the processor, the information included in the current row of the one-dimensional array to include the third target address; determining, by the processor, that first target address is equivalent to the second target address and the third target address based, at least in part, on the information read from the current row of the one-dimensional array, the column of the current row of the branch target buffer containing the second prediction, and the branch encountered within the first instruction stream; executing, by the processor, at least the second instruction and a third instruction present within the second instruction stream; and removing, by the processor, the second instruction stream. |