JP3764019B2 - Branch prediction method, arithmetic device, and calculation device - Google Patents
Branch prediction method, arithmetic device, and calculation device Download PDFInfo
- Publication number
- JP3764019B2 JP3764019B2 JP2000025769A JP2000025769A JP3764019B2 JP 3764019 B2 JP3764019 B2 JP 3764019B2 JP 2000025769 A JP2000025769 A JP 2000025769A JP 2000025769 A JP2000025769 A JP 2000025769A JP 3764019 B2 JP3764019 B2 JP 3764019B2
- Authority
- JP
- Japan
- Prior art keywords
- branch prediction
- branch
- data
- state
- unit
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Expired - Fee Related
Links
Images
Landscapes
- Advance Control (AREA)
Description
【0001】
【発明の属する技術分野】
本発明は分岐予測方法及び演算装置並びに計算装置に係り、特に、分岐命令に応じて分岐予測を行う際に用いられる分岐予測方法及び演算装置並びに計算装置に関する。
【0002】
近年、マイクロプロセッサでは、処理の高速化のためパイプライン方式を用いたマイクロプロセッサが主流となっている。また、マイクロプロセッサでは、処理の高速化のため分岐命令が発生した場合、分岐の度合いに応じて分岐方向を予測し、処理を進めることにより処理を高速化する方式が取られている。
【0003】
パイプライン方式に分岐予測を適用した場合、分岐予測をミスした時に、パイプラインの各スロットに現在の処理に関与しないパイプラインバブルが生じ、性能が大幅に低下する。パイプラインバブルは、マイクロプロセッサの動作周波数の上昇に伴い、マイクロプロセッサの全体の性能に大きく影響を与える。
【0004】
そこで、高い分岐予測ヒット率をめざしてさまざまな分岐予測手法が提案されている。そのなかでも、二段分岐予測手法は、現状最も有効な分岐予測手法である。
【0005】
この二段分岐予測手法では、分岐予測テーブルが正しい方向に更新されるまでには、複数回の分岐ミスを検出する必要があった。特に, スーパースカラ方式のプロセッサでは、複数命令を同時に実行する分、分岐予測ミスの回数が増加し、性能低下への影響が大きくなる。そこで、プロファイリングの結果を容易に分岐予測に反映できる方法が望まれている。
【0006】
【従来の技術】
図1は従来の計算装置の一例のブロック構成図を示す。
【0007】
計算装置1は、演算装置2、メインメモリ3、ハードディスクドライブ4、入力装置5、表示装置6、バス7から構成される。
【0008】
演算装置2は、データの演算を行なう。メインメモリ3は、演算装置2の作業用記憶領域として用いられ、演算すべきデータや命令、演算結果などが一時的に保持される。ハードディスクドライブ4は、演算装置2で実行されるプログラムやデータを記憶する。入力装置5は、キーボードやマウスなどから構成され、プログラムの実行の指示やデータ入力に用いられる。表示装置6は、演算装置2での演算結果などを表示する。バス7は、演算装置2、メインメモリ3、ハードディスクドライブ4、入力装置5、表示装置6を接続する。
【0009】
図2は従来の演算装置の一例のブロック構成図を示す。
【0010】
従来の演算装置2は、キャッシュメモリ11、命令フェッチ部12、命令デコード部13、演算部14、マルチプレクサ13、リオーダバッファ14、制御部15, 分岐予測部16から構成される。
【0011】
キャッシュメモリ11は、主記憶部からの命令、データを保持する。命令フェッチ部12は、キャッシュメモリ11に記憶された情報を順次フェッチする。命令フェッチ部12にフェッチされた命令は、命令デコード部13に供給される。
【0012】
命令デコード部13は, 命令をデコードする。命令デコード部13からの命令は、演算部14に供給される。演算部14は、命令デコード部13からの命令を実行する。演算部14は、整数演算部19、浮動小数点演算部20、機能ユニット21から構成される。整数演算部19は、整数演算を実行する。浮動小数点演算部20は、浮動小数点演算を実行する。機能ユニット21は、予め設定された他の機能を実現する。演算部14で実行された演算結果は、マルチプレクサ15に供給される。マルチプレクサ15は、整数演算部19、浮動小数点演算部20、機能ユニット21のいずれかの演算結果をキャッシュメモリ11に供給する。また、演算部5は、リオーダ要求を出力する。
【0013】
リオーダバッファ16は、演算部14からのリオーダ要求を保持する。リオーダバッファ16に保持されたリオーダ要求は、制御部17に供給される。制御部17は、キャッシュメモリ11、命令フェッチ部12、命令デコード部13、演算部14、マルチプレクサ15, リオーダバッファ16を制御し、命令の実行を制御する。分岐予測部18は、命令コードに応じて分岐予測を行う。
【0014】
図3は従来の演算装置の一例の分岐予測部のブロック構成図を示す。
【0015】
分岐予測部18は、分岐ヒストリレジスタ22、インデックス合成回路23、分岐予測テーブル部24、マルチプレクサ25、分岐予測制御部26から構成される。
【0016】
分岐ヒストリレジスタ22は、分岐予測のヒットあるいはミスの履歴が時間順に保持される。
【0017】
図4は従来の演算装置の一例の分岐ヒストリレジスタデータ構成図を示す。
【0018】
分岐ヒストリレジスタ22は、所定数のビット列から構成される。ビット列の各ビットは、過去の分岐予測に対応している。分岐ヒストリレジスタ22の各ビットには、分岐予測結果に応じた値が記憶される。
【0019】
分岐予測結果に応じた値は、分岐が成功したときに「1」、分岐が失敗したときに「0」とされる。分岐ヒストリレジスタ22に保持されたビット列は、インデックス合成回路23に供給される。
【0020】
インデックス合成回路23は、制御部17からのプログラムカウント値と分岐ヒストリレジスタ22からの分岐ヒストリ値とを合成する。インデックス合成回路23での合成結果に応じて分岐予測テーブル部24が参照される。
【0021】
分岐予測テーブル部24は、n個の分岐予測テーブル24−1〜24−nから構成される。分岐予測テーブル24−1〜24−nは、プログラムカウント値に応じて選択される。分岐予測データは、選択された分岐予測テーブル24−xから分岐ヒストリレジスタ22の値に応じて選択される。ここで、分岐予測テーブル24−xは、分岐予測テーブル24−1〜24−nのうちの所望の分岐予測テーブルである。
【0022】
図5は従来の演算装置の一例の分岐予測テーブルのデータ構成図を示す。
【0023】
分岐予測テーブル24−xは、制御部17からのプログラムカウント値ax と分岐ヒストリレジスタ22からの分岐ヒストリ値bm との合成値がアドレスとされ、アドレスに応じた分岐予測データcが記憶されている。
【0024】
分岐予測データcは、2ビットのデータであり、4つの分岐予測状態を示している。分岐予測データcは、「00」のときにはSNT(Strongly not Taken)状態、「01」のときにはWNT(Weakly Not Taken) 状態、「10」のときにはWT(Weakly Taken)状態、ST(Strongly Taken)状態を示す。
【0025】
SNT状態は分岐しない状態、WNT状態は分岐が少行なわれる状態、WT状態は多少分岐する状態、STは分岐予測する状態を示す。
【0026】
分岐予測テーブル部24は、インデックス合成回路23をアドレスとされ、分岐予測データcが読み出される。分岐予測テーブル部24から読み出された分岐予測データcは、制御部17に供給される。制御部17は、分岐予測制御部18からの分岐予測データcに応じて分岐命令を投機的に実行する。
【0027】
図6は従来の演算装置の一例の動作説明図を示す。
【0028】
図6で、SNT状態で分岐予測ミスが発生した場合、分岐予測ミスが分岐ヒストリ値に反映される。分岐ヒストリ値によって、分岐予測データが決定され、SNT状態を示す「00」が分岐予測データとして出力される。
【0029】
また、SNT状態で分岐予測がヒットした場合、分岐予測ヒットが分岐ヒストリ値に反映される。SNT状態で分岐予測がヒットした場合、分岐予測がヒットする確率が向上したので、分岐予測データはWNT状態を示す「01」が分岐予測データとして出力される。
【0030】
WNT状態で分岐予測をミスした場合には、分岐予測データがSNT状態を示す「00」に戻される。WNT状態で分岐予測がヒットした場合には、さらに、分岐予測がヒットする確率が向上するので、分岐予測データはWT状態を示す「10」に変更される。また、WT状態で分岐予測がミスした場合には、分岐予測データは、WNT状態を示す「01」に変更される。
【0031】
さらに、WT状態で分岐予測がミスした場合、分岐予測データはWNT状態の戻される。WT状態で分岐予測がヒットした場合には、分岐予測データはST状態を示す「11」に変更される。
【0032】
このように、分岐予測データcは、分岐ヒストリ値に応じて変更されていた。また、プログラムカウント値に応じて分岐予測テーブル15−1〜15−nを切り換えることにより、プログラム位置に応じた分岐予測制御を可能としていた。
【0033】
【発明が解決しようとする課題】
しかるに、従来の分岐予測方法では、分岐ヒストリ、及び、プログラムカウント値によって予測分岐データが決定されていたため、分岐ヒストリに分岐予測結果が蓄積されないと、正確な分岐予測が行えないなどの問題点があった。
【0034】
本発明は上記の点に鑑みてなされたもので、正確な分岐予測が行える演算装置及び分岐予測方法並びに計算装置を提供することを目的とする。
【0035】
【課題を解決するための手段】
本発明は、分岐予測の結果に応じて分岐予測の状態を示す分岐予測データを決定し、該分岐予測データに応じて分岐予測を行う演算装置において、前記分岐予測データを保持する分岐予測テーブルと、前記分岐予測の履歴を保持するレジスタと、前記分岐予測の履歴に対応した分岐予測補助データを保持する分岐予測補助テーブルと、前記分岐予測更新データを保持する分岐方向遷移テーブルと、分岐予測を制御する制御部とを有し、前記制御部は、前記レジスタに保持された分岐予測の履歴に基づいて前記分岐予測補助テーブルより分岐予測補助データを読み出し、前記分岐予測補助データに基づいて前記分岐方向遷移テーブルから前記分岐予測更新データを読み出し、前記分岐予測更新データに基づいて前記分岐予測テーブルを更新することを特徴とする。
【0036】
本発明によれば、分岐予測の成否に応じて最適な分岐予測データを得ることができるため、正確な分岐予測が可能となり、また、分岐予測の履歴に応じて分岐予測の方向に重み付けを行なうことができ、迅速に正確な分岐予測を行なうことができる。
【0042】
【発明の実施の形態】
図7は本発明の一実施例のブロック構成図を示す。同図中、図2と同一構成部分には同一符号を付し、その説明は省略する。また、計算装置全体の構成も図1と同一であるので、その説明は省略する。
【0043】
本実施例の演算装置100は、分岐予測部101の構成が図1の演算装置とは相違する。
【0044】
図8は本発明の一実施例の分岐予測部のブロック構成図を示す。同図中、図3と同一構成部分には同一符号を付し、その説明は省略する。
【0045】
分岐予測部101は、分岐ヒストリレジスタ22、インデックス合成回路23、分岐予測テーブル部24、マルチプレクサ25、分岐予測制御部26に加えて、分岐予測修正回路102を有する。分岐予測修正回路102は、プロファイル情報テーブル103、分岐予測補助テーブル部104、分岐方向遷移テーブル部105、マルチプレクサ106、107から構成される。
【0046】
プロファイル情報テーブル103は、プロファイル情報を記憶する。プロファイル情報は、分岐予測補助テーブル部104の更新を制御するための情報である。プロファイル情報は、対応するビットが「1」に設定されているときには、分岐予測補助テーブル部103から出力される分岐予測補助データを固定にし、対応するビットが「0」に設定されているときには、分岐予測補助テーブル部104からの分岐予測補助データを更新可能にする。分岐予測補助テーブル部104は、分岐予測補助データを保持する。
【0047】
図9は本発明の一実施例の分岐予測補助テーブル部のデータ構成図を示す。
【0048】
分岐予測補助テーブル部104は、m個の分岐予測補助テーブル104−1〜104−mから構成される。分岐補助テーブル103−xは、nビットのビット列から構成される。ビット列は、rフィールド及びsフィールドの2つのビットフィールドから構成される。rフィールドには、過去の分岐予測のヒット・ミスの履歴が記憶される。sフィールドには、分岐方向遷移テーブル部104を選択するための値が記憶される。分岐予測補助テーブル部104は、分岐予測制御部26からのエントリによりデータ(r、s)を出力する。分岐予測補助テーブル部104の出力は、マルチプレクサ106を介して分岐予測制御部26に供給される。
【0049】
分岐方向遷移テーブル部105は、2n =m個の分岐方向遷移テーブル105−1〜105−mから構成される。分岐方向遷移テーブル105−1〜105−mは、分岐予測制御部26からの分岐予測データをエントリとして、分岐予測更新データを出力する。分岐予測更新データは、分岐予測データと同様に、「00」、「01」、「10」、「11」から構成される。分岐予測更新データ「00」は、分岐予測データと同様にSNT状態を示す。分岐予測更新データ「01」は、分岐予測データと同様にWNT状態を示す。分岐予測更新データ「10」は、分岐予測データと同様にWT状態を示す。分岐予測更新データ「11」は、分岐予測データと同様にST状態を示す。
【0050】
図10は本発明の一実施例の分岐方向遷移テーブルのデータ構成図を示す。
【0051】
分岐方向遷移テーブル105−xは、sフィールドの値によってm個の分岐方向遷移テーブル105−1〜105−mから選択される。選択された分岐方向遷移テーブル105−xは、分岐予測データが「00」、「01」、「10」、「11」がエントリとされている。分岐方向遷移テーブル105−xは、分岐予測データ「00」、「01」、「10」、「11」毎に4ビットのビット列が設定されている。ビット列は、1ビット目が分岐予測更新データ「00」に対応しており、2ビット目が分岐予測更新データ「01」に対応しており、3ビット目が分岐予測更新データ「10」に対応しており、4ビット目が分岐予測更新データ「11」に対応している。ビットの値が「1」の分岐予測更新データが出力される。
【0052】
例えば、sフィールド値により分岐方向遷移テーブル105−1〜105−mから分岐方向遷移テーブル105−xが選択されたとする。また、このときの分岐予測データが「01」であるとする。
【0053】
図10において分岐方向遷移テーブル105−xの遷移エントリ「01」のビット列は、「0010」である。ビット列「0010」は、3ビット目が「1」である。ビット列の3ビット目は、分岐予測データ「10」に対応する。よって、分岐予測データ「10」が出力される。
【0054】
なお、分岐方向遷移テーブル105−1〜105−mのビットパターンは、SNT状態に遷移が行われ易いビットパターンや、WNT状態やWN状態に遷移が行なわれ易いビットパターンや、ST状態に遷移が行なわれ易いビットパターンから構成される。このビットパターンにより遷移の重み付けが行なわれる。このような分岐方向遷移テーブル105−1〜105−mから分岐履歴に応じてヒューリスティックに分岐方向遷移テーブルを選択する。例えば、分岐履歴に「Taken」が多い場合には、ST状態、WT状態方向へのスレッシュホールドが低く、SNT状態、WNT状態方向へのスレッシュホールドが高く設定された分岐方向遷移テーブルを選択する。また、「Not−Taken」が多い場合には、ST状態、WT状態方向へのスレッシュホールドが高く、SNT状態、WNT状態方向へのスレッシュホールドが低く設定された分岐方向遷移テーブルを選択する。
【0055】
マルチプレクサ107には、sフィールドの値が供給される。マルチプレクサは、sフィールドの値によって、分岐方向遷移テーブル部105−xからの出力分岐予測データを選択出力する。
【0056】
マルチプレクサ107で選択出力された分岐予測更新データは、分岐予測制御部26に供給される。分岐予測制御部26は、マルチプレクサ107からの分岐予測更新データにより分岐ヒストリテーブル部24の対応する分岐予測データを更新する。
【0057】
更新された分岐予測データは、マルチプレクサ25を介して分岐予測制御部26に供給され、分岐予測に用いられる。
【0058】
また、分岐予測制御部26は、分岐予測補助テーブル部104からのrフィールドの出力値に応じてsフィールドの値を更新する。例えば、rフィールドの値の「0」の割合が所定の値より多い場合、すなわち、分岐予測にミスが割合より多い場合には、対応するsフィールドの値を更新する。sフィールドの値を更新することにより、分岐方向遷移テーブル部105で選択される分岐方向遷移テーブル105−xが切り換えられる。分岐予測制御部26は、分岐予測データに応じて制御部17を制御して、分岐予測されたデータを更新する。
【0059】
図11は本発明の一実施例の分岐予測部の動作フローチャートを示す。
【0060】
ステップS1は、制御部17からの分岐予測結果により、分岐予測がヒットしたかミスしたかを判断する。ステップS1で分岐予測結果がヒットであると判断された場合、ステップS6が実行される。ステップS6で、分岐予測結果に応じて分岐ヒストリレジスタ22が更新される。
【0061】
また、ステップS1で、分岐予測結果がミスであると判断された場合、ステップS2が実行される。
【0062】
ステップS2は、分岐ヒストリレジスタを参照する。ステップS3は、分岐ヒストリレジスタの参照結果から分岐予測の正当率が所定の正当率以上か否かを判定する。正当率は、分岐ヒストリレジスタの全ビットのうちの「1」のビット占める割合から算出される。
【0063】
ステップS3は、この割合が所定の値以上であるか否かを判定する。ステップS3で、正当率が所定の値以上であると判断されると、そのまま処理を終了する。また、ステップS3で、正当率が所定の値以下のときは、ステップS4が実行される。
【0064】
ステップS4は、最適な遷移エントリを選択する。ステップS4では、まず、分岐ヒストリレジスタのビットパターンに応じて分岐予測補助表を参照され、ビットパターンに応じた分岐予測補助値が取得される。次に、分岐予測補助値に応じて分岐方向遷移テーブルが参照され、最適な遷移エントリが取得される。
【0065】
ステップS5は、ステップS4で取得された最適遷移エントリを分岐予測更新データとして出力する。
【0066】
ステップS6で、ステップS5で出力された分岐予測更新データにより分岐予測テーブル部24を更新する。
【0067】
図12は本発明の一実施例の動作説明図を示す。
【0068】
上記の動作によれば、SNT状態からWNT状態、WNT状態からSNT状態、WNT状態からWT状態、WT状態からWNT状態、WT状態からST状態、ST状態からWT状態への遷移の確率を自由に設定できる。
【0069】
例えば、図12に示すようにSNT状態からWNT状態への遷移の確率を50パーセント、WNT状態からSNT状態への遷移の確率を10パーセント、WNT状態からWT状態への遷移の確率を40パーセント、WT状態からWNT状態への遷移の確率を20パーセント、WT状態からST状態への、ST状態からWT状態への遷移の確率を70パーセントに設定できる。図12の遷移状態では、例えば、SNT状態で分岐予測がヒットすれば、50パーセントの確率で、WNT状態に遷移する。
【0070】
以上、本実施例によれば、分岐ミスを低減するような分岐方向遷移テーブルを使用することができるので、パイプラインプロセッサにおける分岐予測ミスによるパイプラインバブルを低減させることができる。よって、マイクロプロセッサの実効処理性能を向上させることができる。
【0071】
なお、本実施例は、下記の発明を含む。
【0072】
請求項5において、前記分岐予測データ修正手段は、前記分岐予測の成否の履歴に応じて予め重み付けされた複数の分岐予測変更テーブルから所定の分岐予測変更テーブルを選択し、選択された分岐予測更新テーブルより前記分岐予測データに応じた分岐予測更新データを読み出し、前記分岐予測データとすることを有することを特徴とする演算装置。
【0073】
請求項5又は6において、前記分岐予測データ修正手段は、前記分岐予測データが記憶された分岐予測テーブルから前記前記分岐命令に応じた分岐予測データを取得する分岐予測データ取得手段と、前記分岐予測データに応じて分岐予測補助データを取得する分岐予測補助データ取得手段と、前記遷移の方向の重みが異なる記憶された複数の分岐予測更新テーブルから前記分岐予測補助データに応じた分岐予測更新テーブルを選択し、前記分岐予測データに応じた分岐予測更新データを出力する分岐予測更新テーブル選択手段と、前記分岐予測更新テーブルからの分岐予測更新データに応じてに前記分岐予測テーブルを更新する分岐予測テーブル更新手段とを有することを特徴とする演算装置。
【0074】
請求項5乃至7において、前記分岐予測データ修正手段が、予め設定されたプロファイル情報に応じて前記分岐予測データの遷移方向の重み付けを設定することを特徴とする演算装置。
【0075】
【発明の効果】
上述の如く、本発明によれば、分岐予測の成否に応じて最適な分岐予測データを得ることができるため、正確な分岐予測が可能となり、また、分岐予測の履歴に応じて分岐予測の方向に重み付けを行なうことができ、迅速に正確な分岐予測を行なうことができる。
【図面の簡単な説明】
【図1】従来の計算装置の一例のブロック構成図である。
【図2】従来の演算装置の一例のブロック構成図である。
【図3】従来の演算装置の一例の分岐予測部のブロック構成図である。
【図4】従来の演算装置の一例の分岐ヒストリレジスタのデータ構成図である。
【図5】従来の演算装置の一例の分岐予測テーブル部のデータ構成図である。
【図6】従来の演算装置の一例の動作説明図である。
【図7】本発明の一実施例のブロック構成図である。
【図8】本発明の一実施例の分岐予測部のブロック構成図である。
【図9】本発明の一実施例の分岐予測補助テーブル部のデータ構成図である。
【図10】本発明の一実施例の分岐方向遷移テーブルのデータ構成図である。
【図11】本発明の一実施例の分岐予測部の動作フローチャートである。
【図12】本発明の一実施例の動作説明図である。
【符号の説明】
1 計算装置
2 演算装置
3 メインメモリ
4 ハードディスクドライブ
5 入力装置
6 表示装置
7 バス
11 キャッシュメモリ
12 命令フェッチ部
13 命令デコード部
14 演算部
15 マルチプレクサ
16 リオーダバッファ
17 制御部
22 分岐ヒストリレジスタ
23 インデックス合成回路
24 分岐予測テーブル部
25 マルチプレクサ
26 分岐予測制御部
100 演算装置
101 分岐予測部
102 分岐予測修正回路
103 プロファイル情報テーブル
104 分岐予測補助テーブル部
105 分岐方向遷移テーブル部
106,107 マルチプレクサ[0001]
BACKGROUND OF THE INVENTION
The present invention relates to a branch prediction method, an arithmetic device, and a calculation device, and more particularly to a branch prediction method, an arithmetic device, and a calculation device that are used when branch prediction is performed according to a branch instruction.
[0002]
In recent years, microprocessors using a pipeline system have become the mainstream in order to increase processing speed. Further, in the microprocessor, when a branch instruction is generated for speeding up the processing, a method of predicting the branch direction according to the degree of branching and advancing the processing is employed.
[0003]
When branch prediction is applied to the pipeline method, when a branch prediction is missed, a pipeline bubble that does not participate in the current processing is generated in each slot of the pipeline, and the performance is significantly reduced. Pipeline bubbles greatly affect the overall performance of the microprocessor as the operating frequency of the microprocessor increases.
[0004]
Therefore, various branch prediction methods have been proposed aiming at a high branch prediction hit rate. Among them, the two-stage branch prediction method is the most effective branch prediction method at present.
[0005]
In this two-stage branch prediction method, it is necessary to detect a plurality of branch misses before the branch prediction table is updated in the correct direction. In particular, in a superscalar processor, the number of branch prediction errors increases as multiple instructions are executed simultaneously, and the impact on performance degradation increases. Therefore, a method that can easily reflect the result of profiling in branch prediction is desired.
[0006]
[Prior art]
FIG. 1 is a block diagram showing an example of a conventional computing device.
[0007]
The
[0008]
The
[0009]
FIG. 2 is a block diagram showing an example of a conventional arithmetic device.
[0010]
The conventional
[0011]
The
[0012]
The
[0013]
The
[0014]
FIG. 3 is a block diagram of a branch prediction unit as an example of a conventional arithmetic device.
[0015]
The
[0016]
The branch history register 22 stores a history of hits or misses in branch prediction in order of time.
[0017]
FIG. 4 shows a block diagram of a branch history register data as an example of a conventional arithmetic unit.
[0018]
The
[0019]
The value corresponding to the branch prediction result is “1” when the branch is successful, and is “0” when the branch is unsuccessful. The bit string held in the
[0020]
The
[0021]
The branch
[0022]
FIG. 5 is a data configuration diagram of a branch prediction table as an example of a conventional arithmetic device.
[0023]
In the branch prediction table 24-x, a combined value of the program count value ax from the
[0024]
The branch prediction data c is 2-bit data and indicates four branch prediction states. The branch prediction data c is SNT (Strongly not Taken) state when “00”, WNT (Weakly Not Taken) state when “01”, WT (Weakly Taken) state, ST (Strongly Taken) state when “10”. Indicates.
[0025]
The SNT state indicates a state where no branching occurs, the WNT state indicates a state where branching is performed little, the WT state indicates a state where some branching occurs, and ST indicates a state where branching is predicted.
[0026]
The branch
[0027]
FIG. 6 shows an operation explanatory diagram of an example of a conventional arithmetic device.
[0028]
In FIG. 6, when a branch prediction error occurs in the SNT state, the branch prediction error is reflected in the branch history value. Branch prediction data is determined based on the branch history value, and “00” indicating the SNT state is output as branch prediction data.
[0029]
When the branch prediction hits in the SNT state, the branch prediction hit is reflected in the branch history value. When the branch prediction hits in the SNT state, the probability that the branch prediction hits has improved, so that “01” indicating the WNT state is output as branch prediction data for the branch prediction data.
[0030]
When the branch prediction is missed in the WNT state, the branch prediction data is returned to “00” indicating the SNT state. When the branch prediction hits in the WNT state, the probability that the branch prediction hits is further improved, so that the branch prediction data is changed to “10” indicating the WT state. When the branch prediction is missed in the WT state, the branch prediction data is changed to “01” indicating the WNT state.
[0031]
Furthermore, if the branch prediction misses in the WT state, the branch prediction data is returned to the WNT state. When the branch prediction hits in the WT state, the branch prediction data is changed to “11” indicating the ST state.
[0032]
As described above, the branch prediction data c is changed according to the branch history value. Further, the branch prediction tables 15-1 to 15-n are switched according to the program count value, thereby enabling branch prediction control according to the program position.
[0033]
[Problems to be solved by the invention]
However, in the conventional branch prediction method, since the predicted branch data is determined by the branch history and the program count value, there is a problem that accurate branch prediction cannot be performed unless the branch prediction result is accumulated in the branch history. there were.
[0034]
The present invention has been made in view of the above points, and an object thereof is to provide an arithmetic device, a branch prediction method, and a calculation device that can perform accurate branch prediction.
[0035]
[Means for Solving the Problems]
The present invention provides a branch prediction table that stores branch prediction data in an arithmetic unit that determines branch prediction data indicating a branch prediction state according to a branch prediction result, and performs branch prediction according to the branch prediction data. A branch prediction history table, a branch prediction auxiliary table holding branch prediction auxiliary data corresponding to the branch prediction history, a branch direction transition table holding the branch prediction update data, and branch prediction. A control unit for controlling, the control unit reads branch prediction auxiliary data from the branch prediction auxiliary table based on a branch prediction history held in the register, and the branch based on the branch prediction auxiliary data Read the branch prediction update data from the direction transition table, and update the branch prediction table based on the branch prediction update data And wherein the door.
[0036]
According to the present invention, optimal branch prediction data can be obtained according to the success or failure of branch prediction, so that accurate branch prediction is possible, and the direction of branch prediction is weighted according to the branch prediction history. And accurate branch prediction can be performed quickly.
[0042]
DETAILED DESCRIPTION OF THE INVENTION
FIG. 7 shows a block diagram of an embodiment of the present invention. In the figure, the same components as in FIG. Further, the configuration of the entire computing device is the same as that shown in FIG.
[0043]
The
[0044]
FIG. 8 is a block diagram of a branch prediction unit according to an embodiment of the present invention. In the figure, the same components as those in FIG.
[0045]
The
[0046]
The profile information table 103 stores profile information. Profile information is information for controlling the update of the branch prediction
[0047]
FIG. 9 shows a data configuration diagram of the branch prediction auxiliary table part of one embodiment of the present invention.
[0048]
The branch prediction
[0049]
The branch direction
[0050]
FIG. 10 is a data configuration diagram of a branch direction transition table according to an embodiment of the present invention.
[0051]
The branch direction transition table 105-x is selected from the m branch direction transition tables 105-1 to 105-m according to the value of the s field. In the selected branch direction transition table 105-x, branch prediction data “00”, “01”, “10”, and “11” are entries. In the branch direction transition table 105-x, a 4-bit bit string is set for each branch prediction data “00”, “01”, “10”, and “11”. In the bit string, the first bit corresponds to the branch prediction update data “00”, the second bit corresponds to the branch prediction update data “01”, and the third bit corresponds to the branch prediction update data “10”. The fourth bit corresponds to the branch prediction update data “11”. Branch prediction update data whose bit value is “1” is output.
[0052]
For example, it is assumed that the branch direction transition table 105-x is selected from the branch direction transition tables 105-1 to 105-m by the s field value. Further, it is assumed that the branch prediction data at this time is “01”.
[0053]
In FIG. 10, the bit string of the transition entry “01” in the branch direction transition table 105-x is “0010”. In the bit string “0010”, the third bit is “1”. The third bit of the bit string corresponds to branch prediction data “10”. Therefore, branch prediction data “10” is output.
[0054]
Note that the bit patterns of the branch direction transition tables 105-1 to 105-m are a bit pattern that is easily changed to the SNT state, a bit pattern that is easily changed to the WNT state or the WN state, and a transition to the ST state. It consists of bit patterns that are easy to perform. Transition weighting is performed by this bit pattern. A branch direction transition table is selected heuristically from the branch direction transition tables 105-1 to 105-m according to the branch history. For example, when there are many “Taken” in the branch history, the branch direction transition table in which the threshold in the ST state and WT state directions is low and the threshold in the SNT state and WNT state directions is set high is selected. When there are many “Not-Takens”, a branch direction transition table in which thresholds in the ST state and WT state directions are high and thresholds in the SNT state and WNT state directions are set low is selected.
[0055]
The multiplexer 107 is supplied with the value of the s field. The multiplexer selectively outputs the output branch prediction data from the branch direction transition table unit 105-x according to the value of the s field.
[0056]
The branch prediction update data selected and output by the multiplexer 107 is supplied to the branch
[0057]
The updated branch prediction data is supplied to the branch
[0058]
Further, the branch
[0059]
FIG. 11 shows an operation flowchart of the branch predicting unit of the embodiment of the present invention.
[0060]
In step S1, it is determined from the branch prediction result from the
[0061]
If it is determined in step S1 that the branch prediction result is a mistake, step S2 is executed.
[0062]
Step S2 refers to the branch history register. In step S3, it is determined from the reference result of the branch history register whether or not the branch prediction validity rate is equal to or higher than a predetermined validity rate. The correct rate is calculated from the ratio of the bits of “1” in all the bits of the branch history register.
[0063]
In step S3, it is determined whether or not this ratio is equal to or greater than a predetermined value. If it is determined in step S3 that the correct rate is greater than or equal to a predetermined value, the process is terminated. In step S3, when the validity rate is equal to or less than a predetermined value, step S4 is executed.
[0064]
In step S4, an optimum transition entry is selected. In step S4, first, the branch prediction auxiliary table is referred to according to the bit pattern of the branch history register, and the branch prediction auxiliary value corresponding to the bit pattern is acquired. Next, the branch direction transition table is referred to according to the branch prediction auxiliary value, and the optimum transition entry is acquired.
[0065]
In step S5, the optimum transition entry acquired in step S4 is output as branch prediction update data.
[0066]
In step S6 , the branch
[0067]
FIG. 12 is an operation explanatory diagram of one embodiment of the present invention.
[0068]
According to the above operation, the probability of transition from SNT state to WNT state, WNT state to SNT state, WNT state to WT state, WT state to WNT state, WT state to ST state, ST state to WT state can be freely set Can be set.
[0069]
For example, as shown in FIG. 12, the probability of transition from the SNT state to the WNT state is 50%, the probability of transition from the WNT state to the SNT state is 10%, the probability of transition from the WNT state to the WT state is 40%, The probability of transition from the WT state to the WNT state can be set to 20%, and the probability of transition from the WT state to the ST state to ST state to the WT state can be set to 70%. In the transition state of FIG. 12, for example, if the branch prediction hits in the SNT state, the state transitions to the WNT state with a probability of 50 percent.
[0070]
As described above, according to the present embodiment, since a branch direction transition table that reduces branch misses can be used, pipeline bubbles due to branch prediction mistakes in the pipeline processor can be reduced. Therefore, the effective processing performance of the microprocessor can be improved.
[0071]
This example includes the following inventions.
[0072]
6. The branch prediction data correction unit according to
[0073]
7. The branch prediction data acquisition unit according to
[0074]
8. The arithmetic unit according to
[0075]
【The invention's effect】
As described above , according to the present invention, optimal branch prediction data can be obtained according to the success or failure of branch prediction, so that accurate branch prediction is possible, and the direction of branch prediction according to the branch prediction history. Can be weighted, and accurate branch prediction can be performed quickly.
[Brief description of the drawings]
FIG. 1 is a block configuration diagram of an example of a conventional computing device.
FIG. 2 is a block configuration diagram of an example of a conventional arithmetic device.
FIG. 3 is a block configuration diagram of a branch prediction unit of an example of a conventional arithmetic device.
FIG. 4 is a data configuration diagram of a branch history register as an example of a conventional arithmetic device.
FIG. 5 is a data configuration diagram of a branch prediction table unit of an example of a conventional arithmetic device.
FIG. 6 is an operation explanatory diagram of an example of a conventional arithmetic device.
FIG. 7 is a block diagram of an embodiment of the present invention.
FIG. 8 is a block configuration diagram of a branch prediction unit according to an embodiment of the present invention.
FIG. 9 is a data configuration diagram of a branch prediction auxiliary table unit according to an embodiment of the present invention.
FIG. 10 is a data configuration diagram of a branch direction transition table according to an embodiment of the present invention.
FIG. 11 is an operation flowchart of a branch prediction unit according to an embodiment of the present invention.
FIG. 12 is an operation explanatory diagram of an embodiment of the present invention.
[Explanation of symbols]
DESCRIPTION OF
Claims (5)
前記分岐予測データを保持する分岐予測テーブルと、
前記分岐予測の履歴を保持するレジスタと、
前記分岐予測の履歴に対応した分岐予測補助データを保持する分岐予測補助テーブルと、
前記分岐予測更新データを保持する分岐方向遷移テーブルと、
分岐予測を制御する制御部とを有し、
前記制御部は、前記レジスタに保持された分岐予測の履歴に基づいて前記分岐予測補助テーブルより分岐予測補助データを読み出し、
前記分岐予測補助データに基づいて前記分岐方向遷移テーブルから前記分岐予測更新データを読み出し、
前記分岐予測更新データに基づいて前記分岐予測テーブルを更新することを特徴とする演算装置。In a calculation device that determines branch prediction data indicating a branch prediction state according to a branch prediction result, and performs branch prediction according to the branch prediction data,
A branch prediction table holding the branch prediction data;
A register for holding the branch prediction history;
A branch prediction auxiliary table holding branch prediction auxiliary data corresponding to the branch prediction history;
A branch direction transition table that holds the branch prediction update data;
A control unit for controlling branch prediction,
The control unit reads branch prediction auxiliary data from the branch prediction auxiliary table based on a branch prediction history held in the register,
Read the branch prediction update data from the branch direction transition table based on the branch prediction auxiliary data,
An arithmetic unit that updates the branch prediction table based on the branch prediction update data.
前記制御部は、前記複数のテーブルのうち前記分岐予測補助データに対応したテーブルを選択することを特徴とする請求項1記載の演算装置。The branch direction transition table includes a plurality of tables storing information with different weights of the transition direction of branch prediction,
The arithmetic unit according to claim 1, wherein the control unit selects a table corresponding to the branch prediction auxiliary data from the plurality of tables.
前記rビットのフィールドには、前記分岐予測の結果の履歴が格納されており、
前記sビットのフィールドには、前記分岐方向遷移テーブルを選択するための値が格納されており、
前記sビットのフィールドは、前記rビットのフィールドの値に応じて更新されることを特徴とする請求項1又は2記載の演算装置。The branch prediction auxiliary table holds n-bit data composed of an r-bit field and an s-bit field ,
The r-bit field stores a history of the branch prediction result,
In the field of s bits, a value for selecting the branch direction transition table is stored.
3. The arithmetic device according to claim 1, wherein the s-bit field is updated according to a value of the r-bit field .
分岐予測の履歴に応じて分岐予測補助データを取得し、
前記取得された分岐予測補助データに応じて分岐予測更新データを取得し、
取得された分岐予測更新データに基づいて前記分岐予測データを更新することを特徴とする分岐予測方法。In a branch prediction method for determining branch prediction data indicating a branch prediction state according to a branch prediction result, and performing branch prediction according to the branch prediction data,
Acquire branch prediction auxiliary data according to the branch prediction history,
Acquiring branch prediction update data according to the acquired branch prediction auxiliary data;
A branch prediction method, wherein the branch prediction data is updated based on the acquired branch prediction update data.
Priority Applications (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2000025769A JP3764019B2 (en) | 2000-02-02 | 2000-02-02 | Branch prediction method, arithmetic device, and calculation device |
| US09/736,163 US7085920B2 (en) | 2000-02-02 | 2000-12-15 | Branch prediction method, arithmetic and logic unit, and information processing apparatus for performing brach prediction at the time of occurrence of a branch instruction |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2000025769A JP3764019B2 (en) | 2000-02-02 | 2000-02-02 | Branch prediction method, arithmetic device, and calculation device |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| JP2001216158A JP2001216158A (en) | 2001-08-10 |
| JP3764019B2 true JP3764019B2 (en) | 2006-04-05 |
Family
ID=18551582
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP2000025769A Expired - Fee Related JP3764019B2 (en) | 2000-02-02 | 2000-02-02 | Branch prediction method, arithmetic device, and calculation device |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JP3764019B2 (en) |
Families Citing this family (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| WO2012127666A1 (en) * | 2011-03-23 | 2012-09-27 | 富士通株式会社 | Arithmetic processing device, information processing device, and arithmetic processing method |
-
2000
- 2000-02-02 JP JP2000025769A patent/JP3764019B2/en not_active Expired - Fee Related
Also Published As
| Publication number | Publication date |
|---|---|
| JP2001216158A (en) | 2001-08-10 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| KR101059335B1 (en) | Efficient Use of JHT in Processors with Variable Length Instruction Set Execution Modes | |
| JP3542020B2 (en) | Processor device and processor control method for executing instruction cache processing for instruction fetch alignment over multiple predictive branch instructions | |
| US7941607B1 (en) | Method and system for promoting traces in an instruction processing circuit | |
| US7085920B2 (en) | Branch prediction method, arithmetic and logic unit, and information processing apparatus for performing brach prediction at the time of occurrence of a branch instruction | |
| JP3871883B2 (en) | Method for calculating indirect branch targets | |
| US7949854B1 (en) | Trace unit with a trace builder | |
| US6457120B1 (en) | Processor and method including a cache having confirmation bits for improving address predictable branch instruction target predictions | |
| US7461238B2 (en) | Simple load and store disambiguation and scheduling at predecode | |
| KR100395763B1 (en) | A branch predictor for microprocessor having multiple processes | |
| US7814298B1 (en) | Promoting and appending traces in an instruction processing circuit based upon a bias value | |
| US8943300B2 (en) | Method and apparatus for generating return address predictions for implicit and explicit subroutine calls using predecode information | |
| US7987342B1 (en) | Trace unit with a decoder, a basic-block cache, a multi-block cache, and sequencer | |
| EP3306467A1 (en) | Branch predictor that uses multiple byte offsets in hash of instruction block fetch address and branch pattern to generate conditional branch predictor indexes | |
| US7953961B1 (en) | Trace unit with an op path from a decoder (bypass mode) and from a basic-block builder | |
| US8832418B2 (en) | Efficient branch target address cache entry replacement | |
| EP4020187A1 (en) | Segmented branch target buffer based on branch instruction type | |
| US8751776B2 (en) | Method for predicting branch target address based on previous prediction | |
| EP2035919A1 (en) | A fast and inexpensive store-load conflict scheduling and forwarding mechanism | |
| JP2010524107A (en) | Method for reducing power consumption by processor, processor, and information processing system | |
| JP3764019B2 (en) | Branch prediction method, arithmetic device, and calculation device | |
| EP4020167A1 (en) | Accessing a branch target buffer based on branch instruction information | |
| JP2002278752A (en) | Instruction execution result prediction device | |
| JPWO2004068337A1 (en) | Information processing device | |
| US8015359B1 (en) | Method and system for utilizing a common structure for trace verification and maintaining coherency in an instruction processing circuit | |
| JP2001236225A (en) | Arithmetic device, branch prediction method, and information processing device |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20040824 |
|
| A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20050712 |
|
| A521 | Written amendment |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20050909 |
|
| A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20051025 |
|
| A521 | Written amendment |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20051219 |
|
| TRDD | Decision of grant or rejection written | ||
| A01 | Written decision to grant a patent or to grant a registration (utility model) |
Free format text: JAPANESE INTERMEDIATE CODE: A01 Effective date: 20060117 |
|
| A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20060118 |
|
| R150 | Certificate of patent or registration of utility model |
Free format text: JAPANESE INTERMEDIATE CODE: R150 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20100127 Year of fee payment: 4 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20110127 Year of fee payment: 5 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20110127 Year of fee payment: 5 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20120127 Year of fee payment: 6 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20130127 Year of fee payment: 7 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20130127 Year of fee payment: 7 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20140127 Year of fee payment: 8 |
|
| LAPS | Cancellation because of no payment of annual fees |