JPH08101776A - Compiler device and loop optimizing control method - Google Patents

Compiler device and loop optimizing control method

Info

Publication number
JPH08101776A
JPH08101776A JP23667094A JP23667094A JPH08101776A JP H08101776 A JPH08101776 A JP H08101776A JP 23667094 A JP23667094 A JP 23667094A JP 23667094 A JP23667094 A JP 23667094A JP H08101776 A JPH08101776 A JP H08101776A
Authority
JP
Japan
Prior art keywords
loop
optimization
unrolling
program
control method
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.)
Granted
Application number
JP23667094A
Other languages
Japanese (ja)
Other versions
JP3544397B2 (en
Inventor
Masatoshi Haraguchi
正寿 原口
Masakazu Hayashi
正和 林
Naoji Nakahira
直司 中平
Makoto Komagata
真 駒形
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fujitsu Ltd
Original Assignee
Fujitsu Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Fujitsu Ltd filed Critical Fujitsu Ltd
Priority to JP23667094A priority Critical patent/JP3544397B2/en
Publication of JPH08101776A publication Critical patent/JPH08101776A/en
Application granted granted Critical
Publication of JP3544397B2 publication Critical patent/JP3544397B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Landscapes

  • Devices For Executing Special Programs (AREA)

Abstract

PURPOSE: To perform the loop optimizations worth executing on the condition that the performance is improved and in a combination for performance improvement without individually executing plural loop optimizations. CONSTITUTION: Characteristics or program/hardware are analyzed by a loop optimization control part 20, and optimization groups which should not be simultaneously operated or require restrictions for simultaneous operation are recognized based on the analysis result to determine whether plural optimization items should be executed respectively or not, and the execution condition for execution and the execution order of optimizations are determined. Thereafter, loop optimizations are executed by a loop deforming part 30 in accordance with the execution order and the execution condition determined for optimization items to be executed.

Description

【発明の詳細な説明】Detailed Description of the Invention

【0001】[0001]

【産業上の利用分野】本発明は,最適化機能を有するコ
ンパイラの最適化効果を促進させるコンパイラ装置およ
びループ最適化制御方法に関するものである。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a compiler device and a loop optimization control method for promoting the optimization effect of a compiler having an optimization function.

【0002】近年,コンピュータシステムの高速化の要
求に伴い,1サイクルで複数の命令を同時に実行できる
プロセッサやベクトル演算が可能なマシンが数多く開発
されている。それに伴い,それらのマシンを有効に運用
するために,コンパイラに対する要求も高まってきてい
る。特に,プログラムにおけるループ部分は実行時間の
比重が高いため,ループ内部のコードを最適に生成する
ことが翻訳/実行時間の短縮に大きく貢献することにな
る。本発明は,ループで行われる種々の最適化を有効に
活用するためのループ最適化制御技術に関するものであ
り,産業上の利用性は広い。
In recent years, in response to the demand for high speed computer systems, many processors capable of simultaneously executing a plurality of instructions in one cycle and machines capable of vector arithmetic have been developed. Along with this, the demand for compilers is increasing in order to operate these machines effectively. In particular, since the loop portion of a program has a high proportion of execution time, optimally generating the code inside the loop greatly contributes to shortening the translation / execution time. The present invention relates to a loop optimization control technique for effectively utilizing various optimizations performed in a loop, and has wide industrial applicability.

【0003】[0003]

【従来の技術】従来のコンパイラ装置におけるループ最
適化として,ループ・アンローリング,ソフトウェア・
パイプライニング等,個々のループ最適化はいくつか存
在する。例えば,ループ・アンローリングに関しては,
回転数をループ内で使用される浮動小数点型および整数
型のレジスタ数とループ内で使用される演算数からアン
ローリング数を算出する方法が知られている(特開平4
−307624号公報,特開平4−307625号公
報)。また,ループ内のそれぞれの演算に対して各演算
の実行時間重みを付加してループ内演算数を算出し,そ
の値からアンローリング数を算出する方法もすでに提案
されている。
2. Description of the Related Art As loop optimization in a conventional compiler device, loop unrolling, software
There are several individual loop optimizations such as pipelining. For example, regarding loop unrolling,
There is known a method of calculating the unrolling number from the number of floating-point type and integer type registers used in the loop and the number of operations used in the loop.
No. 307624, JP-A No. 4-307625). In addition, a method has already been proposed in which the execution time weight of each operation is added to each operation in the loop to calculate the number of operations in the loop, and the unrolling number is calculated from the calculated value.

【0004】図9ないし図12は,従来のループ最適化
の例であって,特に図9はループ・アンローリング,図
10はリネーミング,図11および図12はソフトウェ
ア・パイプライニングの例を示す。
9 to 12 show examples of conventional loop optimization. In particular, FIG. 9 shows loop unrolling, FIG. 10 shows renaming, and FIGS. 11 and 12 show examples of software pipelining. .

【0005】ループ・アンローリングは,例えば図9に
示すように,ループ変数Iを含む演算を複数個に展開
し,ループ回数を少なくする最適化である。リネーミン
グは,図10(A)に示すようなプログラム(X1〜X
5は異なる任意の変数)に対して,演算間の依存性をで
きるだけ少なくするため,変数名を変えても結果に影響
のない変数を抽出して,他の変数名に置き換える最適化
である。図10の例の場合,1番目と2番目の演算にお
ける変数名Aを変数名Bに変え,3番目と4番目の演算
における変数名Aを変数名Cに変えることにより,B
=X1,X2=BとC=X3,X4=CとA=X5
の演算間の依存性をなくしている。なお,ここでいうリ
ネーミングとは,レジスタ割り当てあるいは命令スケジ
ューリングで行われるレジスタ・リネーミングではな
く,最適化フェーズの中でも比較的前段階で行われる中
間言語に対するリネーミングである。
Loop unrolling is an optimization in which an operation including a loop variable I is expanded into a plurality of operations to reduce the number of loops, as shown in FIG. 9, for example. The renaming is performed by the program (X1 to X) as shown in FIG.
5 is an optimization for extracting variables that do not affect the result even if the variable names are changed and replacing them with other variable names in order to minimize the dependency between operations for different arbitrary variables. In the case of the example in FIG. 10, B is changed by changing the variable name A in the first and second operations to the variable name B and changing the variable name A in the third and fourth operations to the variable name C.
= X1, X2 = B and C = X3, X4 = C and A = X5
It eliminates the dependency between operations. Note that the renaming here is not renaming of registers performed by register allocation or instruction scheduling, but renaming of an intermediate language performed relatively earlier in the optimization phase.

【0006】ソフトウェア・パイプライニングによる最
適化は,以下のとおりである。例えば,図11(A)に
示す命令列がソースプログラムから生成されたあるルー
プを構成する命令列であったとする。ループが図11
(A)のように4回アンローリングされた場合,図11
(B)に示すように4回転分の命令列を一まとまりとし
て処理する。これらの命令列を通常のようにスケジュー
リングすると,図12(A)に示すようになる。これを
プロローグ部とエピローグ部に分けてパイプライン化す
ると図12(B)に示すようになり,さらにリスケジュ
ーリングすると,図12(C)に示すようになる。これ
により,ループ内の演算にかかる時間を短縮することが
できる。図12(A)では,ループ内の演算に7τかか
っていたものが,図12(B)では,4τに短縮されて
いる。
The optimization by software pipelining is as follows. For example, it is assumed that the instruction sequence shown in FIG. 11A is an instruction sequence forming a certain loop generated from the source program. Loop is Figure 11
When unrolled four times as in (A), FIG.
As shown in (B), the instruction sequence for four rotations is processed as a group. When these instruction sequences are scheduled as usual, the result becomes as shown in FIG. When this is divided into a prologue portion and an epilogue portion and pipelined, it becomes as shown in FIG. 12B, and when it is rescheduled, it becomes as shown in FIG. 12C. As a result, it is possible to reduce the time required for the calculation in the loop. The calculation in the loop took 7τ in FIG. 12A, but is shortened to 4τ in FIG. 12B.

【0007】以上のように,各種のループ最適化の技術
が知られているが,従来,種々のループ最適化をプログ
ラム/ハードウェアの特性を把握して統括的に制御する
方法は考えられていなかった。したがって,パターンマ
ッチング的に最適化条件を満たすというだけで,種々の
最適化を動作させる傾向にあった。このため,理論的に
は実行性能を向上させる最適化であっても有効に活用し
きれず,かえって性能が落ちることさえあった。ループ
・アンローリングのループ展開しすぎによるスピル生成
などは最適化の逆効果としてよく知られる例である。
As described above, various loop optimization techniques are known, but conventionally, a method of comprehensively controlling various loop optimizations by grasping the characteristics of the program / hardware has been considered. There wasn't. Therefore, there is a tendency to operate various optimizations simply by satisfying the optimization conditions for pattern matching. For this reason, theoretically, even optimizations that improve execution performance could not be used effectively, and performance could even decline. Spill generation due to excessive loop unrolling of loop unrolling is a well-known example of the adverse effect of optimization.

【0008】なお,スピルとはレジスタ不足によるメモ
リへのロード,ストアのことをいう。プログラムで使用
される変数,およびコンパイラの内部で生成される変数
には,高速化のためできるだけレジスタが割り当てられ
る。しかし,レジスタの数に制限があり,レジスタが不
足したとき,コンパイラではメモリ上の領域を利用す
る。メモリへのアクセスはロード,ストア命令を介して
行われるため,レジスタを利用する場合と比較して大変
遅く,性能低下を及ぼす原因となる。
The spill refers to loading and storing in the memory due to register shortage. Registers are allocated to variables used in the program and variables generated inside the compiler as much as possible for speeding up. However, the number of registers is limited, and when the registers are insufficient, the compiler uses the area on memory. Access to the memory is performed via load and store instructions, so it is much slower than when using registers, which causes performance degradation.

【0009】また,従来の技術では,ループの並列化を
促す最適化がループ・アンローリング,ソフトウェア・
パイプライニング,リネーミング程度しかなかった。特
に,近年スーパースカラやVLIWというようなアーキ
テクチャが広く用いられるようになってきており,この
ようなアーキテクチャに適した新しい最適化の技術が望
まれる。
Further, in the conventional technique, optimization for promoting parallelization of loops is performed by loop unrolling, software
There was only pipelining and renaming. In particular, in recent years, architectures such as superscalar and VLIW have been widely used, and new optimization techniques suitable for such architecture are desired.

【0010】[0010]

【発明が解決しようとする課題】従来の技術では以下の
ような問題があった。 1.オプション解析情報,ハードウェア解析情報,プロ
グラム解析情報を統括的に管理し,その情報をもとに個
々の最適化を制御する部分がないため,個々の最適化が
それぞれの実施条件を満足するというだけで実施されて
しまう。このため,かえって性能が低下する場合があ
る。
The prior art has the following problems. 1. It manages option analysis information, hardware analysis information, and program analysis information in a centralized manner, and there is no part that controls each optimization based on that information, so each optimization satisfies each execution condition. It will be carried out only. As a result, the performance may deteriorate.

【0011】2.上記1に関連して,それぞれは意味の
ある最適化であるが,それらが同時に動作することによ
ってかえって性能が落ちる場合がある。また,優先度を
つけて制御(抑止)すべき最適化もある。
2. In connection with the above 1, each is a significant optimization, but the simultaneous operation of them may rather reduce the performance. There is also optimization that should be controlled (suppressed) with priorities.

【0012】3.上記1に関連して,それぞれは意味の
ある最適化であるが,それらが同時に動作するために
は,何らかの制御または制限を加えることをしないとか
えって性能が落ちる場合がある。
3. In connection with the above 1, each is a significant optimization, but in order for them to operate at the same time, some control or restriction may not be applied, and the performance may be rather degraded.

【0013】4.プログラムの解析は今までにも行われ
ていたが,その解析のレベルが低く,ループ最適化後の
コードは最適な状態には至っていない。例えば,今まで
のアンローリング数の決定は,種々の最適化が実施され
る前のループ内部の変数の依存関係を解析するため,最
適コードを生成するのには限界があった。したがって,
ループ内変数の依存関係から実施できる最適化を予想
し,その上でその最適化が行われた後のループ内で使用
される変数の依存関係を把握して使用レジスタ数を見積
もることによりアンローリング数を決定する必要があ
る。
4. Although program analysis has been done so far, the level of analysis is low and the code after loop optimization has not reached the optimum state. For example, the determination of the unrolling number up to now has a limit in generating the optimum code because it analyzes the dependency relationships of variables inside the loop before various optimizations are performed. Therefore,
Unrolling by predicting the optimization that can be implemented from the dependency of variables in the loop, and then grasping the dependency of variables used in the loop after the optimization is performed and estimating the number of registers used You need to determine the number.

【0014】5.上記4で示したプログラム解析の解析
レベル制御が高度でない。プログラム解析によって得ら
れる情報としては,最適化実施後の変数の依存関係を加
味した使用レジスタ数,実行時間重みの付いた演算数等
様々な情報がある。これらの情報を翻訳レベルを参照し
て獲得するかしないかを決定することによって,プログ
ラムの解析レベルを段階的に制御することができる必要
がある。
5. The analysis level control of the program analysis shown in 4 above is not advanced. As the information obtained by the program analysis, there are various information such as the number of registers used in consideration of the dependency relation of variables after the optimization, the number of operations with execution time weighting. It is necessary to be able to control the analysis level of the program stepwise by deciding whether or not to obtain such information by referring to the translation level.

【0015】本発明は上記問題点の解決を図り,複数の
ループ最適化を個々に実施するのではなく,プログラム
/ハードウェアの特性をオプティマイズレベルに応じて
解析し,実施する価値のあるループ最適化をより性能が
上がる条件で,かつより性能の上がる組合せで実施でき
るようにすることを目的とする。
The present invention solves the above-mentioned problems, and rather than individually executing a plurality of loop optimizations, it analyzes the characteristics of the program / hardware according to the optimization level and performs loop optimization which is worth implementing. The purpose is to enable the optimization under conditions that improve performance and in combinations that improve performance.

【0016】[0016]

【課題を解決するための手段】図1は本発明の原理説明
図である。図1において,10はCPUおよびメモリ等
からなる処理装置,11はソースプログラムをオブジェ
クトプログラムに翻訳するコンパイラ,12はソースプ
ログラムの入力および初期処理を行うフロントエンド
部,13はプログラム構造を解析するプログラム構造解
析部,14は最適化処理を行うループ最適化部,15は
変数等に対してレジスタを割り付けるレジスタ割り付け
部,16は命令実行順序等のスケジューリングを行う命
令スケジューリング部,17はスケジューリング結果に
従ってオブジェクトコードを生成するコード生成部を表
す。また,20はループ最適化制御部であって,オプシ
ョン情報解析部21,ハードウェア情報解析部22,プ
ログラム解析部23,ループ最適化制御決定部24から
なるもの,30はループ変形部であって,ループ・アン
ローリング,ループ・リダクション(詳しくは後述す
る),ソフトウェア・パイプライニング等の最適化処理
を行うものを表す。
FIG. 1 is a diagram illustrating the principle of the present invention. In FIG. 1, 10 is a processing device including a CPU and memory, 11 is a compiler that translates a source program into an object program, 12 is a front end unit that performs input and initial processing of the source program, and 13 is a program that analyzes the program structure. A structure analysis unit, a loop optimization unit for performing optimization processing, a register allocation unit for allocating registers to variables and the like, an instruction scheduling unit for scheduling instruction execution order and the like, and an object according to a scheduling result. Represents a code generator that generates code. Reference numeral 20 denotes a loop optimization control unit, which includes an option information analysis unit 21, a hardware information analysis unit 22, a program analysis unit 23, and a loop optimization control determination unit 24, and 30 denotes a loop transformation unit. , Loop unrolling, loop reduction (details will be described later), software pipelining, and other optimization processing.

【0017】フロントエンド部12,プログラム構造解
析部13,レジスタ割り付け部15,命令スケジューリ
ング部16およびコード生成部17の処理については従
来と同様でよいので,詳しい説明は省略する。
The processes of the front end unit 12, the program structure analyzing unit 13, the register allocating unit 15, the instruction scheduling unit 16 and the code generating unit 17 may be the same as the conventional ones, and a detailed description thereof will be omitted.

【0018】本発明では,ループ最適化部14のプロロ
ーグ部にループ最適化制御部20を設けることによっ
て,ループ内で実施する価値のある最適化を選択/制御
しておき,ループ変形部30にその旨を伝達することに
より,任意のプログラム/アーキテクチャ上で,翻訳/
実行性能を向上できるループ最適化のみを実施する。
In the present invention, the loop optimization control section 20 is provided in the prologue section of the loop optimization section 14 to select / control a valuable optimization to be executed in the loop, and the loop transformation section 30 can be selected. By transmitting this, translation / translation on any program / architecture
Only perform loop optimization that can improve execution performance.

【0019】従来の最適化では,最適化同士がお互いに
干渉し合うことがなく,2つの最適化が同時に動作する
ことにより性能が低下することがあったが,この発明に
より効果的に最適化を動作させることができる。
In the conventional optimization, the optimizations did not interfere with each other, and the two optimizations operated at the same time, but the performance sometimes deteriorated. However, the present invention effectively optimizes the optimizations. Can be operated.

【0020】図1に示すように,ループ最適化制御部2
0は,オプション情報解析部21,ハードウェア情報解
析部22,プログラム解析部23,ループ最適化制御決
定部24に細分化される。
As shown in FIG. 1, the loop optimization control unit 2
0 is subdivided into an option information analysis unit 21, a hardware information analysis unit 22, a program analysis unit 23, and a loop optimization control determination unit 24.

【0021】オプション情報解析部21/ハードウェア
情報解析部22では,指定されたハードウェア/オプシ
ョン環境をプログラム解析部23/ループ最適化制御決
定部24に伝達する。例えば,オプション情報として,
オプティマイズレベル,各最適化の実施/抑止等の情
報,また,ハードウェア情報として,レジスタ数,キャ
ッシュサイズ,ターゲットのマシンが持つ各命令の実行
時間等の情報がある。これらの情報を,あるテーブル上
に記録し,後の処理過程にメッセージとして伝達する方
法をとる。
The option information analysis unit 21 / hardware information analysis unit 22 transfers the designated hardware / option environment to the program analysis unit 23 / loop optimization control determination unit 24. For example, as option information,
The optimization level, information such as implementation / suppression of each optimization, and the hardware information include the number of registers, cache size, and execution time of each instruction of the target machine. This information is recorded on a table and transmitted as a message to the subsequent processing steps.

【0022】プログラム解析部23では,オプション解
析により決定したオプティマイズレベルに依存して,ど
の程度のプログラム解析をするのかを決定する。プログ
ラム解析で収集する情報の例として以下の3つがある。
The program analysis unit 23 determines how much program analysis is to be performed, depending on the optimization level determined by the option analysis. There are the following three examples of information collected by program analysis.

【0023】1.ループ内に出現する演算数を各演算の
実行時間重みを加味してカウントした値。 2.ループ内で使用される変数間の依存関係を把握し,
実際に実施されるときと同じ条件かあるいはそれより緩
い条件で,ループ変形部30で実際に行われる最適化を
予想した結果。
1. A value that counts the number of operations that appear in the loop, adding the execution time weight of each operation. 2. Understand the dependencies between the variables used in the loop,
The result of predicting the optimization actually performed in the loop deforming unit 30 under the same condition as that actually executed or a condition looser than that.

【0024】3.その予想した最適化が実際に実施され
ることを加味した上で,ループ内で使用されるレジスタ
数をループに対してローカルに必要な整数型変数/浮動
小数点型変数,ループに対してグローバルに必要な整数
型変数/浮動小数点型変数に分けて見積もった値。
3. In addition to the fact that the expected optimization is actually implemented, the number of registers used in the loop is set to the integer type variable / floating point type variable required locally for the loop and globally for the loop. Estimated value divided into required integer type variables / floating point type variables.

【0025】上記2において,変数の依存関係を把握す
る方法の一例としては,ループ内の演算を各ノードとし
て作成したダグによる解析法がある。上記3において,
最適化予想を加味する理由は,ループ・リダクションそ
の他のループ最適化により,ループに対してローカルな
変数が増加するためである(リネーミング以外の最適化
結果を加味している点が今までと違うところである)。
In the above-mentioned item 2, as an example of the method of grasping the variable dependency, there is a Doug analysis method in which the operation in the loop is created as each node. In the above 3,
The reason for adding the optimization prediction is that the variables local to the loop increase due to loop reduction and other loop optimizations (the fact that the optimization results other than renaming are taken into consideration up to now) It's a different place).

【0026】例えば,これらの1,2,3の情報の収集
をオプティマイズレベルに依存して可/不可にすれば,
プログラムの解析レベルを操作することができる。言い
替えれば,翻訳/実行性能を操作することが可能にな
る。さらに具体的には,オプティマイズレベルが低い場
合には,作成できるロードモジュールの実行時間をそれ
ほど追求する必要がないので,翻訳性能が上がるように
1のみの収集を行う方法をとれば,実行性能もある程度
維持でき,かつ,翻訳性能が上がる最適化を導くことが
できる。
For example, if collection of these 1, 2 and 3 information is enabled / disabled depending on the optimization level,
The analysis level of the program can be manipulated. In other words, it becomes possible to manipulate the translation / execution performance. More specifically, if the optimization level is low, it is not necessary to pursue the execution time of the load module that can be created so much. If the method of collecting only 1 is adopted so as to improve the translation performance, the execution performance is also improved. It can be maintained to some extent and can lead to optimization that improves translation performance.

【0027】ループ最適化制御決定部24では,オプシ
ョン情報解析部21,ハードウェア情報解析部22,プ
ログラム解析部23からの一連の情報をもとに実施可能
な最適化を決定する。そして同時に,プログラム/アー
キテクチャの特性を把握し,同時に動作させるべきでな
い最適化を優先度に従って抑止,あるいは制限付きで実
行させるようにループ変形部30に伝達する。この伝達
の方法の一例としては,どういう最適化をどのように実
行させるかを記したテーブルを作成し,それをメッセー
ジとしてループ変形部30に伝達する方法がある。
The loop optimization control decision unit 24 decides an optimizable optimization based on a series of information from the option information analysis unit 21, the hardware information analysis unit 22, and the program analysis unit 23. At the same time, the characteristics of the program / architecture are grasped, and optimizations that should not be operated at the same time are transmitted to the loop transforming unit 30 so as to be suppressed or executed with a restriction according to the priority. As an example of this transmission method, there is a method of creating a table in which what kind of optimization is to be executed and how to perform it, and transmitting it to the loop transforming unit 30 as a message.

【0028】ループ最適化制御決定部24の情報の一つ
であるアンローリング数は,プログラム解析部23での
解析レベルに依存して決定される。最適化予想とそれを
加味したレジスタ数が算出されていれば,ループ変形部
30で行われる最適化を十分に活かし,より並列化効果
のでるアンローリング数を算出できる。アンローリング
数の決定方法の実施例は後述する。
The unrolling number, which is one of the information of the loop optimization control determination unit 24, is determined depending on the analysis level of the program analysis unit 23. If the optimization prediction and the number of registers considering it are calculated, the optimization performed in the loop transforming unit 30 can be fully utilized to calculate the unrolling number with which the parallelization effect can be further obtained. An example of the method for determining the unrolling number will be described later.

【0029】ループ変形部30では,授受したその情報
を参照しながら,ループ変形をする種々の最適化,例え
ば,ループ・アンローリング,本発明に係るループ・リ
ダクション,リネーミング,ソフトウェア・パイプライ
ニング等を実施する。
The loop transforming unit 30 refers to the transmitted and received information, and performs various optimizations for loop transforming, for example, loop unrolling, loop reduction, renaming, software pipelining according to the present invention. Carry out.

【0030】続いて,ループ・リダクションの実現方法
について述べる。ループ・リダクションは,ループ中で
他の演算と依存関係のない変数Qが,Q=Q+α(αは
定数でない)という形で出現し,かつ,アンローリング
が行われた後に行われる特殊なリネーミング処理であ
る。アンローリング後,ループ内に含まれるQ=Q+α
という同じ演算(αが配列の場合には配列の添字が異な
る)に対して,ある1つの演算中の変数Qを除いたすべ
ての変数Qをリネーミングすることにより,Qを含む演
算間のdependencyをなくすことができる。これにより,
特に1サイクルで複数の命令を実行できるプロセッサで
は並列化が大きく促進される。ただし,Qをリネーミン
グしてしまったため,ループ出口における変数Qは総和
演算結果とならない。したがって,ループの前にリネー
ミングした変数Qγ(γ=1,2,3…)を初期化する
処理,ループの後に変数Qに対して変数Qγ(γ=1,
2,3…)を加算する処理が必要となる。このループの
後に出す変数Qに対する補正処理は,Q=Q+Q1,Q
=Q+Q2,Q=Q+Q3,…というような演算ではな
く,余分なレジスタを使用せずに並列化を促進するよう
に,Tree Height Reduction (演算木の高さをできるだ
け小さくし,並列化を促進する最適化)を施す必要があ
る。ただし,ループ・リダクションは総和演算の順序を
変更するため,実行結果に誤差を生じる可能性のある最
適化である。
Next, a method of realizing loop reduction will be described. Loop reduction is a special renaming performed after a variable Q that does not depend on other operations in the loop appears in the form of Q = Q + α (α is not a constant) and unrolling is performed. Processing. After unrolling, Q = Q + α included in the loop
For the same operation (when α is an array, the array subscripts are different), by renaming all variables Q except the variable Q in a certain operation, the dependency between the operations including Q Can be eliminated. By this,
In particular, parallelization is greatly promoted in a processor that can execute a plurality of instructions in one cycle. However, since Q is renamed, the variable Q at the loop exit does not become the sum calculation result. Therefore, the process of initializing the renamed variable Qγ (γ = 1, 2, 3 ...) Before the loop, and the variable Qγ (γ = 1, 1) for the variable Q after the loop
2, 3, ...) are required to be added. The correction process for the variable Q issued after this loop is Q = Q + Q1, Q
= Q + Q2, Q = Q + Q3, etc. Tree Height Reduction (The height of the operation tree is made as small as possible and the parallelization is promoted so that the parallelization is promoted without using extra registers. Optimization) is required. However, since loop reduction changes the order of summation operations, it is an optimization that may cause errors in execution results.

【0031】[0031]

【作用】従来技術では,例えばA,B,C,…という複
数の最適化項目があったとき,まず最適化項目Aについ
ての実施可否/実施条件の判定,実施可の場合に最適化
項目Aの実施,次に最適化項目Bについての実施可否/
実施条件の判定,実施可の場合に最適化項目Bの実施,
次に最適化項目Cについての実施可否/実施条件の判
定,実施可の場合に最適化項目Cの実施,…というよう
にそれぞれ個別に最適化を実施していたのに対し,本発
明では,ループ最適化制御部20を設けることにより,
まず最適化項目A,B,C,…のすべての実施可否/実
施条件を最初に総合的に判定し,最適化の実施予想から
最も効果的な実施条件,実施順番等を決めて,ループ最
適化を行う点が大きく異なる。
In the prior art, when there are a plurality of optimization items such as A, B, C, ..., First, it is determined whether or not the optimization item A can be executed / execution conditions, and if it is, the optimization item A And then whether to implement optimization item B /
Judgment of execution conditions, execution of optimization item B when execution is possible,
Next, the optimization is performed individually for each optimization item C, such as determination of implementation feasibility / implementation conditions, implementation of the optimization item C when implementation is possible, ... By providing the loop optimization control unit 20,
First, all the feasibility / implementation conditions of the optimization items A, B, C, ... Are first comprehensively determined, and the most effective execution conditions, execution order, etc. are determined from the optimization execution prediction, and the loop optimization is performed. There is a big difference in the process of conversion.

【0032】本発明により以下の事項が可能となる。 ・ループ最適化を予想してから,ループ最適化の制御を
することができる(最適化実施後のループ内の依存関係
を把握できるため,高度なプログラム解析および高度な
最適化制御ができる)。
The present invention enables the following items. -It is possible to control loop optimization after anticipating loop optimization (because it is possible to understand the dependency relationships within the loop after optimization is performed, advanced program analysis and advanced optimization control can be performed).

【0033】・オプティマイズレベル等によりプログラ
ム解析のレベルを制御できる(それに依存して,高いオ
プティマイズレベルに対してより並列化効果の高いアン
ローリング数を決定できる)。
The level of program analysis can be controlled by the optimization level or the like (depending on it, the number of unrolling with a higher parallelization effect can be determined for a high optimization level).

【0034】・上記のように,アーキテクチャ/プログ
ラムをコンパイラが高度に解析することにより,動作し
て性能の上がる最適化のみを実施することが可能にな
る。 ・また,同時に動作するとかえって性能が低下するよう
な最適化同士を優先度に従い抑止,あるいは制限付きで
実行することが可能になる。
As described above, the high-level analysis of the architecture / program by the compiler makes it possible to carry out only the optimization that operates and improves the performance. -Also, it is possible to suppress optimizations that may reduce performance rather than to operate simultaneously, or execute them with restrictions, depending on the priority.

【0035】・ループ・リダクションにより並列化が大
きく促進する。 これらの機能(制御)によるより豊富な情報をもとに,
種々の最適化をより効果が上がるように実施/抑止し,
翻訳/実行性能を向上させることができる。
The parallelization is greatly promoted by the loop reduction. Based on more abundant information by these functions (control),
Implement / suppress various optimizations to be more effective,
Translation / execution performance can be improved.

【0036】[0036]

【実施例】図2は,本発明に係るループ・リダクション
の例の説明図である。本発明では,ループ最適化の一つ
として,ループの並列度を高めるための新たなループ変
形を採用する。これをループ・リダクションと呼ぶ。ル
ープ・リダクションは,例えば,図2(A)に示すよう
なループ・アンローリングの結果に対して,ループ中で
他の演算と依存関係のない変数Qを含む演算のうち,そ
の2番目以降の演算における変数Qを,図2(B)に示
すように,それぞれQ1,Q2,Q3とリネーミング
し,Qを含む演算間の相互依存性をなくすことにより,
Q,Q1,Q2,Q3の演算に関する並列実行性を促進
する最適化である。
FIG. 2 is an explanatory diagram of an example of loop reduction according to the present invention. In the present invention, as one of the loop optimizations, a new loop transformation for increasing the parallelism of the loop is adopted. This is called loop reduction. The loop reduction is, for example, for the result of the loop unrolling as shown in FIG. 2A, of the second and subsequent operations among the operations including the variable Q having no dependency relationship with other operations in the loop. By renaming the variable Q in the operation with Q1, Q2, and Q3, respectively, as shown in FIG. 2B, by eliminating the interdependence between the operations including Q,
It is an optimization that promotes parallel executability for the operations of Q, Q1, Q2, and Q3.

【0037】ループ・リダクションは,プログラムの構
造を変えないで単に変数名だけを他の変数名に置き換え
る従来のリネーミングとは異なり,元々は同一に扱われ
るべき変数を異なる変数として扱うものであるから,ル
ープの前に値の初期処理,ループの後に補正処理のよう
な付加的な処理が必要になる。
Unlike the conventional renaming in which only the variable name is simply replaced with another variable name without changing the structure of the program, the loop reduction is to treat variables that should originally be treated as different variables. Therefore, additional processing such as initial value processing before the loop and correction processing after the loop is required.

【0038】図3は,本発明の実施例によるループ最適
化部14の各フェーズを詳細化したフローチャートであ
る。ループ最適化部14に入力されたプログラムは,ル
ープ最適化制御部20に入る。そして,オプション情報
解析部21でオプティマイズレベル,最適化の実施抑止
オプションを解析して各オプションの情報を一覧できる
オプション情報テーブルを作成する。一般的に,あるオ
プションがオプションに連動する(実際には最適化自身
が連動するのであるが)ことはよくある。例えば,オプ
ティマイズレベルを示すオプションが良い例で,オプテ
ィマイズレベルを高いレベルにすると,コンパイラはそ
のプログラムに対して有効と思われる最適化をできるだ
け動かす。したがって,あるオプションによって連動
(抑止)される最適化のチェックが必要となる。すなわ
ち,オプション解析では単に指定されたオプションの認
識だけでなく,それから連動される最適化を解析する。
オプティマイズレベルが最低レベルでループ最適化を行
う必要がない場合には,図3のオプション情報解析部2
1の下のオプティマイズレベルに関する判定でループ最
適化部14から脱出する。
FIG. 3 is a detailed flowchart of each phase of the loop optimizing unit 14 according to the embodiment of the present invention. The program input to the loop optimization unit 14 enters the loop optimization control unit 20. Then, the option information analysis unit 21 analyzes the optimization level and the optimization suppression option and creates an option information table capable of listing information of each option. In general, it is common for an option to be linked to an option (though the optimization itself is linked). For example, the option that indicates the optimization level is a good example, and when the optimization level is set to a high level, the compiler moves the optimization that seems to be effective for the program as much as possible. Therefore, it is necessary to check the optimization linked (suppressed) by a certain option. That is, in the option analysis, not only the recognition of the specified option but also the optimization linked with it is analyzed.
When it is not necessary to perform the loop optimization at the lowest optimization level, the option information analysis unit 2 in FIG.
The loop optimization unit 14 is exited by the determination regarding the optimization level under 1.

【0039】ハードウェア情報解析部22では,ロード
モジュールを実行するマシンの様々な情報,例えば,整
数型/浮動小数点型のレジスタ数,キャッシュサイズ,
各アセンブラ命令の実行時間などを,そのマシンのハー
ドウェア情報としてハードウェア情報テーブルに登録す
る。採取する情報量はオプティマイズレベル等に依存し
て変化する。
In the hardware information analysis unit 22, various information of the machine executing the load module, such as the number of integer type / floating point type registers, the cache size,
The execution time of each assembler instruction is registered in the hardware information table as the hardware information of the machine. The amount of information collected varies depending on the optimization level and other factors.

【0040】プログラム解析部23では,オプション情
報解析部21で得られた情報(オプティマイズレベル)
に依存して,プログラム解析のレベルを変動する。プロ
グラムで解析すべき情報としては,例えば以下のものが
ある。
In the program analysis section 23, the information (optimization level) obtained in the option information analysis section 21.
The level of program analysis varies depending on the. The information to be analyzed by the program is, for example, as follows.

【0041】1.ループ内に出現する演算に対して,ハ
ードウェア情報テーブル上に記録された各演算の重みを
加味した実行時間をカウントした値(実行時間重み付き
演算数)。
1. A value obtained by counting the execution time in which the weight of each operation recorded in the hardware information table is added to the operation appearing in the loop (the number of operations with execution time weighting).

【0042】2.ループ内で使用される変数間の依存関
係を把握し,かつオプション情報テーブルを参照するこ
とによって実施許可が与えられていることを考慮して,
ループ変形部30で実際に行われる最適化を予想した結
果。
2. Considering the dependency relationship between variables used in the loop, and considering that the execution permission is given by referring to the option information table,
Results of prediction of optimization actually performed by the loop transformation unit 30.

【0043】3.その予想した最適化が実際に実施され
ることを加味した上で,ループ内で使用されるレジスタ
数をループに対してローカルに必要な整数型変数/浮動
小数点型変数,ループに対してグローバルに必要な整数
型変数/浮動小数点型変数に分けて見積もった値。ここ
で,最適化予想を加味する理由は,リネーミング,ルー
プ・リダクションといったループ最適化により,ループ
に対してローカルに必要な変数が増加するためである。
3. In addition to the fact that the expected optimization is actually implemented, the number of registers used in the loop is set to the integer type variable / floating point type variable required locally for the loop and globally for the loop. Estimated value divided into required integer type variables / floating point type variables. Here, the reason why the optimization prediction is added is that the number of variables locally required for the loop increases due to loop optimization such as renaming and loop reduction.

【0044】これらのどの情報が得られるかをオプティ
マイズレベルに依存して変化させることによって,プロ
グラムの解析レベルを変動することができる。上記の例
では,項目1に対して,項目2,3はより高度な解析レ
ベルで実施することになる。プログラム解析部23でも
プログラム情報テーブルが作成され,上記の情報が記録
される。
The analysis level of the program can be changed by changing which of these pieces of information is obtained depending on the optimization level. In the above example, for items 1, items 2 and 3 will be performed at a higher analysis level. The program analysis unit 23 also creates a program information table and records the above information.

【0045】ループ最適化制御決定部24では,オプシ
ョン情報テーブル,ハードウェア情報テーブル,プログ
ラム情報テーブル,およびこのループ最適化制御決定部
24が持つ最適化の優先順位テーブルを参照して,どの
最適化をどのような順序でどのように実施するかを決定
する。この最適化優先順位テーブルには,各最適化に対
して,その優先順位と,自分より優先順位の高い最適化
が動作したときに抑止されるか否かのフラグ,また,そ
の最適化が実施されるための条件(例えば,ループ・リ
ダクションであったならばループ・アンローリングが実
施されていること)等が記録されている。
The loop optimization control determination unit 24 refers to the option information table, the hardware information table, the program information table, and the optimization priority table of the loop optimization control determination unit 24 to determine which optimization Determine in what order and how. In this optimization priority table, for each optimization, its priority, a flag indicating whether or not the optimization with a higher priority than itself is suppressed, and the optimization is performed. The conditions (for example, if it is a loop reduction, the loop unrolling is performed) and the like are recorded.

【0046】ループ最適化制御決定部24では,プログ
ラム情報テーブルから予想される最適化を認識し,ルー
プ制御情報テーブル中に実施か抑止かを登録する。ただ
し,その設定の際に,最適化優先順位テーブルを参照
し,同時に実行すべきでない最適化を抑止,あるいは制
限付きで実行するようにする。例えば,ループ・アンロ
ーリングとループ・リダクションが予想された場合,最
適化優先順位テーブルを参照して,ループ・アンローリ
ングを制限付きで実施するという情報を得る。それから
ダグ情報から得たループ変形後のレジスタ数を参照して
(ループ・リダクションによりループに対してローカル
に必要な変数が増えていることが考慮されている),以
下の計算式(1) によりアンローリング数を算出する。
The loop optimization control determining unit 24 recognizes the optimization expected from the program information table and registers in the loop control information table whether it is carried out or suppressed. However, at the time of the setting, the optimization priority table is referred to so that optimizations that should not be executed at the same time are suppressed or executed with restrictions. For example, when loop unrolling and loop reduction are expected, the optimization priority table is referred to obtain information that the loop unrolling is performed with a limitation. Then, referring to the number of registers after loop transformation obtained from the Doug information (considering that the number of variables required locally for the loop is increased by loop reduction), the following formula (1) is used. Calculate the unrolling number.

【0047】関数FUNCでは,ループ内で行われるル
ープ最適化を加味して,第1引数,第2引数で与えられ
るアンローリング数のチューニング値を返す。例えば,
ソフトウェア・パイプライニングが予想されたループの
場合には,ターゲットであるマシンの浮動小数点型の四
則演算の中(除算を除く)で最大の実行時間の倍数であ
る値を返し(ただしUNROLL1は越えない),ルー
プ・リダクションが予想された場合には,下の式(2) で
リダクションを加味して求められた値UNROLL1を
そのまま返すというようなチューニングをする。また,
ソフトウェア・パイプライニング,ループ・リダクショ
ンが予想されるときのアンローリング数はレジスタ数を
越えず,さらに,それらが予想されない時のループのア
ンローリング数でも,アンローリング後のループ内の総
演算数がキャッシュサイズを越してしまわないように考
慮している。
The function FUNC returns the tuning value of the unrolling number given by the first argument and the second argument, taking into account the loop optimization performed in the loop. For example,
In the case of a loop for which software pipelining is expected, it returns a value that is a multiple of the maximum execution time (excluding division) of the four arithmetic operations of the floating-point type of the target machine (however UNROLL1 is not exceeded). ), If loop reduction is expected, tuning is performed such that the value UNROLL1 obtained by adding the reduction in equation (2) below is returned as it is. Also,
The number of unrolling when software pipelining and loop reduction are expected does not exceed the number of registers. Furthermore, even when the number of unrolling loops is not expected, the total number of operations in the loop after unrolling is We are careful not to exceed the cache size.

【0048】 アンローリング数 =FUNC(UNROLL1,UNROLL2,OPT) (1) UNROLL1 =MIN[{(INUM−ILOCAL)/IGLOBAL}, {(RNUM−RLOCAL)/RGLOBAL}] (2) UNROLL2 =(MAX_IST)/IST (3) ・FUNC():最適化OPTが行われることを加味し
て,第1引数,第2引数で与えられるアンローリング数
をチューニングしてその値を返す。
Unrolling number = FUNC (UNROLL1, UNROLL2, OPT) (1) UNROLL1 = MIN [{(INUM-ILOCAL) / IGLOBAL}, {(RNUM-RLOCAL) / RGLOBAL}] (2) UNROLL_ = MAX / IST (3) -FUNC (): In consideration of the optimization OPT being performed, the unrolling number given by the first argument and the second argument is tuned and the value is returned.

【0049】・UNROLL1:最適化後のループ内の
使用変数を見積もって式(2) から決定したアンローリン
グ数。UNROLL1は,基本的にソフトウェア・パイ
プライニング,ループ・リダクションの実施に対して,
ループ内レジスタの再利用がないことを考慮して見積も
った値である(これらの最適化が実施されない時は,ア
ンローリング後,レジスタの再利用が行われることが多
い)。
UNROLL1: The unrolling number determined from the equation (2) by estimating the variables used in the loop after optimization. UNROLL1 is basically for software pipelining and loop reduction.
This is an estimated value in consideration of the fact that the registers in the loop are not reused (when these optimizations are not performed, the registers are often reused after unrolling).

【0050】・UNROLL2:ループ内の各演算に対
して,それぞれの実行時間を重みとして加味して算出し
た総演算数から式(3) により決定したアンローリング
数。 ・MAX_IST:アンローリング後のループ内の時間
重み付き総演算数の最大値。
UNROLL2: An unrolling number determined by the equation (3) from the total number of operations calculated by adding the execution time of each operation as a weight to each operation in the loop. MAX_IST: maximum value of the total number of time-weighted operations in the loop after unrolling.

【0051】・IST:ループに対して算出した時間重
み付き総演算数。 ・OPT:ループ変形をするアンローリング以外のルー
プ最適化(ex.0x0002)。
IST: Time-weighted total number of operations calculated for the loop. -OPT: Loop optimization other than unrolling for loop deformation (ex.0x0002).

【0052】・INUM:システムが持つ整数型レジス
タ数。 ・RNUM:システムが持つ浮動小数点型レジスタ数。 ・ILOCAL:ループに対してローカルに必要な整数
型レジスタ数。
INUM: Number of integer type registers that the system has. -RNUM: The number of floating-point type registers that the system has. ILOCAL: Number of integer type registers required locally for the loop.

【0053】・IGLOBAL:ループに対してグロー
バルに必要な整数型レジスタ数。 ・RLOCAL:ループに対してローカルに必要な浮動
小数点型レジスタ数。 ・RGLOBAL:ループに対してグローバルに必要な
浮動小数点型レジスタ数。
IGLOBAL: The number of integer type registers required globally for the loop. RLOCAL: the number of floating-point type registers required locally for the loop. RGLOBAL: The number of floating-point type registers required globally for the loop.

【0054】以上の関数FUNCによって得られるアン
ローリング数もループ制御情報としてループ制御情報テ
ーブルに登録される。ループ変形部30では,そのルー
プ制御情報テーブルを受け取り,それらの情報に従って
種々の最適化を実施する。例えば,ループ・アンローリ
ング/実施/5回展開,ループ・リダクション/実施,
ソフトウェア・パイプライニング/抑止というようなテ
ーブル上の情報により,種々の最適化を実施/抑止す
る。
The unrolling number obtained by the above function FUNC is also registered in the loop control information table as loop control information. The loop transforming unit 30 receives the loop control information table and performs various optimizations according to the information. For example, loop unrolling / execution / 5 times expansion, loop reduction / execution,
Various optimizations are implemented / suppressed by information on the table such as software pipelining / suppression.

【0055】図4は本発明の実施例による最適化の例を
示す図,図5は本発明の実施例によるループ最適化部の
動作例の説明図,図6および図7は本発明の実施例にお
いて用いられるテーブルの例を示す図である。
FIG. 4 is a diagram showing an example of optimization according to the embodiment of the present invention, FIG. 5 is an explanatory diagram of an operation example of a loop optimizing unit according to the embodiment of the present invention, and FIGS. 6 and 7 are implementations of the present invention. It is a figure which shows the example of the table used in an example.

【0056】以下に,本発明の実施例によるループ最適
化部14が実際のプログラムの入力に対してどのように
動作するかを,図4(A)に示すプログラムA(progra
m A)を例にとって説明する。
A program A (progra) shown in FIG. 4A shows how the loop optimizing unit 14 according to the embodiment of the present invention operates in response to an actual program input.
This will be described by taking m A) as an example.

【0057】コンパイラに対してプログラムAが与えら
れると,プログラムAは図1に示すフロントエンド部1
2,プログラム構造解析部13を通過した後,ループ最
適化部14に入力され,さらに,ループ最適化制御部2
0に到達する。
When the program A is given to the compiler, the program A is the front end unit 1 shown in FIG.
2. After passing through the program structure analysis unit 13, it is input to the loop optimization unit 14, and further, the loop optimization control unit 2
Reach 0.

【0058】図5に示すように,ループ最適化制御部2
0では,まず,オプション情報解析部21が動作し,そ
こでは,オプション指定により高いオプティマイズレベ
ルを要求されていることを認識し,また,リネーミング
抑止オプションが指定されていることを認識する。そし
てさらに,高いオプティマイズレベルで連動する最適化
を認識する。これらの情報を後のフェーズに伝達するた
めに,図6(A)に示すようなオプション情報テーブル
を作成する。
As shown in FIG. 5, the loop optimization control unit 2
In 0, first, the option information analysis unit 21 operates, where it recognizes that a high optimization level is requested by the option specification and recognizes that the renaming suppression option is specified. In addition, it recognizes optimizations that work together at high optimization levels. In order to transmit these pieces of information to a later phase, an option information table as shown in FIG. 6A is created.

【0059】オプション情報テーブルにおけるオプティ
マイズレベルは,次のように分別される。 0:最適化しない 1:低レベルの最適化 2:中レベルの最適化 3:高レベルの最適化 また,オプション情報テーブルにおける最適化は,次の
ように分別される。
The optimization levels in the option information table are classified as follows. 0: No optimization 1: Low-level optimization 2: Medium-level optimization 3: High-level optimization Further, optimization in the option information table is classified as follows.

【0060】 0x0001:ループ・アンローリング 0x0002:ループ・リダクション 0x0004:ソフトウェア・パイプライニング 0x0008:リネーミング すなわち,0x0007は,ループ・アンローリングとループ
・リダクションとソフトウェア・パイプライニングが対
象になることを示す。
0x0001: Loop unrolling 0x0002: Loop reduction 0x0004: Software pipelining 0x0008: Renaming That is, 0x0007 indicates that loop unrolling, loop reduction and software pipelining are targets.

【0061】ハードウェア情報解析部22では,オプシ
ョン情報解析部21の情報(オプティマイズレベル)を
もとに収集する情報を決定し,ハードウェア情報テーブ
ルに登録する。いま,ターゲットとなるマシンの整数型
のレジスタ数が32,浮動小数点型のレジスタ数が3
2,キャッシュサイズ16Kbyteとする。これに対し
て,図6(B)に示すようなハードウェア情報テーブル
が作成される。
The hardware information analysis section 22 determines the information to be collected based on the information (optimization level) of the option information analysis section 21 and registers it in the hardware information table. Now, the target machine has 32 integer type registers and 3 floating point type registers.
2. The cache size is 16 Kbytes. On the other hand, a hardware information table as shown in FIG. 6B is created.

【0062】プログラム解析部23では,図6(A)に
示すオプション情報テーブルを参照し,高いオプティマ
イズレベルが要求されていることを認識し,最も高度な
プログラム解析を行う。図5に示すように,まず,ルー
プ内の各演算に対して各演算の実行時間をその演算の重
みとして付加したループ内の総演算数を算出する。続い
て,ループ内の各演算の依存関係を解析するために,ル
ープに対して,各演算をノードとするダグを作成する。
このダグから,プログラムAのループがループ・リダク
ションできる依存関係であることを認識する。また,ル
ープ・アンローリングできることも認識する(ループの
出口が一つであること等を確認する)。そして,オプシ
ョン情報テーブルを参照して,その最適化が抑止されて
いないかを確認し最終的な予想結果を得る。予想される
最適化は,実際に実施される最適化をすべて含む。した
がって,予想されない最適化が動作することはない。
The program analysis unit 23 refers to the option information table shown in FIG. 6A, recognizes that a high optimization level is required, and performs the most advanced program analysis. As shown in FIG. 5, first, for each operation in the loop, the total number of operations in the loop is calculated by adding the execution time of each operation as the weight of the operation. Then, in order to analyze the dependency of each operation in the loop, a Doug is created for each operation in the loop.
From this Doug, it is recognized that the loop of program A is a dependency that allows loop reduction. Also, recognize that loop unrolling is possible (check that there is only one loop exit). Then, by referring to the option information table, it is confirmed whether or not the optimization is suppressed, and the final expected result is obtained. Expected optimizations include all optimizations that are actually performed. Therefore, unexpected optimizations will not work.

【0063】次に,それらの最適化を加味した上で,ル
ープ内で使用されるレジスタ数を見積もる。ループ内で
使用されるレジスタ数は,ループ内ローカルな整数型/
浮動小数点型,ループ内グローバルな整数型/浮動小数
点型に分けて見積もる。これらの情報は,図6(C)に
示すようなプログラム情報テーブルに登録される。
Next, the number of registers used in the loop is estimated, taking these optimizations into consideration. The number of registers used in the loop is the local integer type /
Estimate separately for floating point type and global integer type / floating point type in loop. These pieces of information are registered in the program information table as shown in FIG.

【0064】ループ最適化制御決定部24では,ハード
ウェア情報テーブル,プログラム情報テーブルを参照し
て,ループ・アンローリング,ループ・リダクションが
予想されていること等を認識する。そして,図7(A)
に示すような最適化優先順位テーブルを参照し,個々の
最適化がどのように実施されるかを決定する。その結果
を,図7(B)に示すようなループ制御情報テーブルに
記録する。最適化優先順位テーブル中の実施条件は,テ
ーブルの第1列に並ぶ最適化が動作する前に必ず動作し
ていなければならない最適化を示す。
The loop optimization control determining unit 24 refers to the hardware information table and the program information table to recognize that loop unrolling, loop reduction, etc. are expected. And FIG. 7 (A)
Refer to the optimization priority table as shown in to determine how each optimization is performed. The result is recorded in the loop control information table as shown in FIG. The implementation condition in the optimization priority table indicates an optimization that must be operating before the optimizations in the first column of the table operate.

【0065】プログラムAでは,ループ・アンローリン
グとループ・リダクションが予想されているので,実施
順序はループ・アンローリング,ループ・リダクショ
ン,実施条件はループ・リダクションを実施できるため
のループ・アンローリングが実施されているから合格と
なる。また,ループ・アンローリングはループ・リダク
ションの実施のため,ループ・アンローリングが単独で
動作したときよりもアンローリング数が少なく抑えられ
ることになる。
In the program A, loop unrolling and loop reduction are expected. Therefore, the execution order is loop unrolling, loop reduction, and the execution condition is loop unrolling for executing loop reduction. Passed because it has been implemented. In addition, since loop unrolling is performed by loop reduction, the number of unrolling operations can be reduced compared to when loop unrolling operates independently.

【0066】最適化優先順位テーブル中の制限付き実施
について説明する。 〔ループ・アンローリング〕テーブル上にあるような並
列化効果のある最適化が予想されている時のループ・ア
ンローリング数は,ループ・アンローリングが単独で実
施された場合と比較して,リネーミング処理によりレジ
スタ数が増えているため,その数は少なく抑えられてい
る。
The restricted implementation in the optimization priority table will be described. [Loop unrolling] The number of loop unrolling when optimization with parallelization effect is expected as shown in the table is larger than that when loop unrolling is performed alone. Since the number of registers is increasing due to the naming process, the number is kept low.

【0067】〔ループ・リダクション/ソフトウェア・
パイプライニング〕ループ・リダクション,またはソフ
トウェア・パイプライニングの実施とループ・アンロー
リングの実施が同時に予想されても,アンローリング数
がある閾値(それぞれの最適化により異なる)より小さ
く,並列化効果が期待できないと判断された場合には,
アンローリング以外の最適化を抑止することがある。
[Loop reduction / software
Pipelining] Even if execution of loop reduction or software pipelining and execution of loop unrolling are expected at the same time, the number of unrolling is smaller than a certain threshold (depending on each optimization), and parallelization effect is expected If it is judged that it is not possible,
Optimizations other than unrolling may be suppressed.

【0068】また,ループ・リダクション,ソフトウェ
ア・パイプライニングが同時に予想される場合には(ア
ンローリングも当然予想されている),基本的には,ル
ープ・リダクションを優先し,ソフトウェア・パイプラ
イニングを抑止するが,上記の理由で,ループ・リダク
ションが抑止された場合でソフトウェア・パイプライニ
ング可能な場合にはソフトウェア・パイプライニングの
み実施する。
When loop reduction and software pipelining are expected at the same time (unrolling is also expected), basically, loop reduction is prioritized and software pipelining is suppressed. However, for the above reason, only software pipelining is performed when loop reduction is suppressed and software pipelining is possible.

【0069】アンローリング数は,プログラム情報テー
ブル上の各レジスタ数を先述した式(1) の計算式に代入
することにより求められる。これにより,OPTで与え
られる最適化を十分意識した並列効果を最大にできるア
ンローリング数(6回)が算出される。このアンローリ
ング数は,図7(B)に示すように,ループ制御情報テ
ーブルのループ・アンローリングの備考欄に記録され
る。プログラムAでは,式(1) の関数は,OPTで与え
られるループ・リダクションの実施予想を識別して,す
でにループ・リダクションによりループに対してローカ
ルに必要な変数が増えることを考慮して見積もったレジ
スタ数から算出済みであるアンローリング数UNROL
L1をそのまま返す。ただし,このUNROLL1があ
る閾値より小さかった場合には,ループ制御情報テーブ
ルのループ・リダクションの欄を抑止にし,ループ・リ
ダクションが予想されなかったとして,アンローリング
回数のチューニングを続け最終的に求まった値を関数値
として返す。
The unrolling number is obtained by substituting the number of registers in the program information table into the calculation formula of the above-mentioned formula (1). As a result, the unrolling number (six times) capable of maximizing the parallel effect with sufficient consideration given to the optimization given by OPT is calculated. This unrolling number is recorded in the remark column of loop unrolling in the loop control information table, as shown in FIG. 7 (B). In program A, the function of expression (1) was estimated by identifying the expected execution of loop reduction given by OPT and considering that the number of variables required for the loop is already increased by loop reduction. Unrolling number UNROLL calculated from the number of registers
L1 is returned as it is. However, when this UNROLL1 is smaller than a certain threshold value, the loop reduction column of the loop control information table is suppressed, and loop reduction is not expected, and tuning of the unrolling number is continued and finally obtained. Returns the value as a function value.

【0070】式(1) のOPTに他の最適化がきた場合の
アンローリング数のチューニングの実施例を挙げてお
く。ソフトウェア・パイプライニングが予想された場合
のアンローリング数は,浮動小数点型の除算を除く四則
演算の実行時間の最大値の倍数,かつUNROLL1を
越えない値となる(下記の式(4) 参照)。ただし,リダ
クションの場合と同様,アンローリング数UNROLL
1がBASEより小さい場合にはループ制御情報テーブ
ルのソフトウェア・パイプライニングの欄を抑止にし,
ソフトウェア・パイプライニングが予想されなかったと
して,アンローリング回数のチューニングを続け最終的
に求まった値を関数値として返す。また,リネーミング
効果がある場合にはリダクションと同様であるが閾値は
なくUNROLL1がそのまま関数値となる。それ以外
は,式(1) のUNROLL1とUNROLL2に対して
ある閾値を設け,UNROLL1がその閾値を越えたら
両者の最小値,UNROLL1とUNROLL2がその
閾値以下であったら両者の最大値,それ以外はUNRO
LL1を返す。
An example of tuning the unrolling number when the OPT in the equation (1) is optimized further will be described. If software pipelining is expected, the unrolling number is a multiple of the maximum execution time of the four arithmetic operations excluding floating-point division, and a value that does not exceed UNROLL1 (see formula (4) below). . However, as in the case of reduction, the unrolling number UNROLL
When 1 is smaller than BASE, the software pipelining column of the loop control information table is suppressed,
Assuming that software pipelining is not expected, the unrolling number is tuned and the value finally obtained is returned as a function value. Further, when there is a renaming effect, it is similar to reduction, but there is no threshold value, and UNROLL1 becomes a function value as it is. Other than that, a certain threshold is set for UNROLL1 and UNROLL2 in the equation (1), and if UNROLL1 exceeds that threshold, the minimum value of both, if UNROLL1 and UNROLL2 are below that threshold, the maximum value of both, otherwise, UNRO
Returns LL1.

【0071】〔ソフトウェア・パイプライニングが予想
されたときのアンローリング数〕 式(1) の関数値=UNROLL1−UNROLL1%BASE (4) ・BASE:ターゲットとなるマシンにおける浮動小数
点型の除算を除く四則演算(ex.fadd,fmult,fsub)の実
行時間の最大値。
[Unrolling Number When Software Pipelining is Predicted] Function value of Expression (1) = UNROLL1-UNROLL1% BASE (4) -BASE: Four rules excluding floating-point division in the target machine Maximum value of execution time of calculation (ex.fadd, fmult, fsub).

【0072】・A%B:AをBで割った余り。また,各
最適化の実施順序は,最適化優先順位テーブルとプログ
ラム情報テーブルを参照して記録される。ただし,算出
したアンローリング数が小さい場合の最適化抑止の情報
はすでにループ制御情報テーブルに記録されているので
その情報も参照する。この結果,プログラムAでは,ル
ープ・アンローリング,ループ・リダクションという実
行順序になる(ループ・アンローリングの制限は,上記
のアンローリング数算出の際にすでに加味してあるの
で,実施の順序さえ伝達すれば良い)。
A% B: A remainder obtained by dividing A by B. The order of execution of each optimization is recorded by referring to the optimization priority table and the program information table. However, since the information of optimization suppression when the calculated unrolling number is small is already recorded in the loop control information table, the information is also referred to. As a result, in program A, the execution order is loop unrolling and loop reduction (the restriction of loop unrolling is already taken into account when calculating the number of unrolling, so even the order of execution is transmitted. Do it).

【0073】ループ変形部30は,ループ制御情報テー
ブルを参照し,ループ・アンローリングとループ・リダ
クションの実施が許可され,その順序で最適化を実施す
ることを認識する。また,アンローリング数6回が最適
であるという情報をそのテーブルから得る。これによ
り,図4(B)のように,まず,6重展開のアンローリ
ングが行われ,その後でループ・リダクションが行われ
る。これにより,ループ・リダクションの効果が最も期
待できるアンローリング数でループを展開することがで
き,ループ内の演算の並列度も最大になる。続いて,ル
ープ・リダクションを図4を例にとって説明する。ルー
プ・リダクションは,図4中のプログラムAのQ=Q+
A(I)というパターンを含むループがアンローリング
されたとき,その2つ目以降のQに対してQ→Qα(α
はアンローリング数(6)−1)という特殊なリネーミ
ングを行う最適化である。これにより,Qを含む演算と
Qαを含む演算の依存関係がすべてなくなり並列化が促
進される。ただし,この補正処理として,ループ前にΣ
Qα=0という演算を入れ,ループの後にQ=Q+ΣQ
αを入れる必要がある(Σはα=1から5までの総
和)。また,このループの後の補正演算は,Tree Heigh
t Reduction により図4(C)に示すループ・リダクシ
ョン後の命令列の後部における加算演算のように,演算
木の高さができるだけ低くなるような形に変形される。
The loop transforming unit 30 refers to the loop control information table and recognizes that the loop unrolling and the loop reduction are permitted and the optimization is performed in that order. In addition, the information that the unrolling number 6 is optimal is obtained from the table. As a result, as shown in FIG. 4 (B), first, unrolling of the sixfold expansion is performed, and then loop reduction is performed. As a result, the loop can be unrolled with the number of unrolling at which the effect of loop reduction can be expected most, and the parallelism of the operations in the loop is maximized. Next, loop reduction will be described with reference to FIG. The loop reduction is Q = Q + of program A in FIG.
When a loop including the pattern A (I) is unrolled, Q → Qα (α
Is an optimization that performs a special renaming of the unrolling number (6) -1). As a result, there is no dependency between the operation including Q and the operation including Qα, and parallelization is promoted. However, as this correction processing, Σ
Insert the operation of Qα = 0, and after the loop, Q = Q + ΣQ
It is necessary to insert α (Σ is the sum of α = 1 to 5). The correction operation after this loop is Tree Heigh
By the t Reduction, the height of the operation tree is changed to a shape as low as possible, as in the addition operation in the rear part of the instruction sequence after the loop reduction shown in FIG.

【0074】前述したアンローリング数のチューニング
値を返す関数FUNCのアルゴリズムの具体例を図8に
示す。図8では,ループ・アンローリングが予想されて
いることが前提となって行われる処理を示している。図
8において,SPはソフトウェア・パイプライニング,
retはFUNCの関数値(算出されたアンローリング
数)を表す。また,MAX(A,B)はA,Bの最大
値,MIN(A,B)はA,Bの最小値を表す関数であ
る。
FIG. 8 shows a specific example of the algorithm of the function FUNC that returns the tuning value of the unrolling number described above. FIG. 8 shows processing performed on the assumption that loop unrolling is expected. In FIG. 8, SP is software pipelining,
ret represents a function value of FUNC (calculated unrolling number). MAX (A, B) is a function that represents the maximum value of A and B, and MIN (A, B) is a function that represents the minimum value of A and B.

【0075】まず,リダクションが予想されたループ
に対する処理として,リダクション可で,かつUNRO
LL1が閾値1以上であれば,UNROLL1を関数値
として返す。
First, as processing for a loop for which reduction is expected, reduction is possible and UNRO
If LL1 is greater than or equal to the threshold 1, UNROLL1 is returned as a function value.

【0076】次に,ソフトウェア・パイプライニング
が予想されたループに対する処理として,ソフトウェア
・パイプライニングが可で,かつUNROLL1が前述
したBASE以上であれば,(UNROLL1−UNR
OLL1%BASE)を関数値として返す。
Next, as a process for a loop for which software pipelining is expected, if software pipelining is possible and UNROLL1 is equal to or higher than the above-mentioned BASE, (UNROLL1-UNR
ALL1% BASE) is returned as a function value.

【0077】リネーミングが予想されたループに対す
る処理として,リネーミング可であれば,UNROLL
1を関数値として返す。 上記以外の場合,ノーマル・ループに対する処理であ
り,以下の処理を行う。
As a process for a loop for which renaming is expected, if renaming is possible, UNROLL
Returns 1 as the function value. In cases other than the above, the processing is for a normal loop, and the following processing is performed.

【0078】・UNROLL1が閾値2より大きけれ
ば,UNROLL1とUNROLL2のうち小さいほう
を関数値として返す。 ・UNROLL2が閾値2以下の場合,UNROLL1
とUNROLL2のうち大きいほうを関数値として返
す。
If UNROLL1 is larger than the threshold value 2, the smaller one of UNROLL1 and UNROLL2 is returned as a function value. If UNROLL2 is less than or equal to threshold 2, UNROLL1
And UNROLL2, whichever is larger is returned as a function value.

【0079】・それ以外の場合にはUNROLL1を関
数値として返す。 以上のような処理によって,次のような作用効果があ
る。例えば従来のループ最適化にさらに本発明に係るル
ープ・リダクションを加えた場合を想定する。
In other cases, UNROLL1 is returned as a function value. The above processing has the following effects. For example, it is assumed that the loop reduction according to the present invention is further added to the conventional loop optimization.

【0080】1.ループ内部の演算数および使用変数が
多く,かつ,ループ・アンローリングできる場合で,ル
ープ・リダクションできるパターンがループ中に出現し
たとき,ループ内で使用する変数をリネーミングして,
別の変数にしてしまうと,ループ内で使用される変数が
さらに増加して,レジスタ割り当て処理でスピルを生成
する可能性がある。本発明では,ループ最適化を予想し
て,事前に使用レジスタ数を適切に見積もることが可能
であるため,スピルの生成などを回避することができ
る。
1. When the number of operations and variables used in the loop are large, and loop unrolling is possible, and when a pattern that allows loop reduction appears in the loop, the variables used in the loop are renamed,
If another variable is used, the number of variables used in the loop will be further increased, and spill may be generated in the register allocation process. According to the present invention, it is possible to appropriately estimate the number of registers to be used in advance by predicting loop optimization, so that it is possible to avoid spill generation and the like.

【0081】2.上記1に関連して,それぞれは意味の
ある最適化であるが,それらが同時に動作することによ
ってかえって性能が落ちるような場合,すなわち,上記
1の例で挙げたようなループに対して,ループ・アンロ
ーリング,ループ・リダクションを同時に実施すると,
スピルを生成する可能性があるため,ループ・リダクシ
ョンを抑止し,ループ・アンローリングのみを実行させ
るというような何らかの制御が必要となる場合に,その
適切な制御が可能になる。また,例えば,ループ・リダ
クションとソフトウェア・パイプライニングが同時に実
行予想されるとき,同時に動作するとかえって性能が落
ちる可能性があるため,より並列化効果の高いループ・
リダクションを優先させるような制御も可能になる。
2. In relation to 1 above, each is a meaningful optimization, but if they work at the same time, the performance is rather degraded, that is, for the loops given in the example of 1 above,・ When unrolling and loop reduction are performed at the same time,
Since there is a possibility of generating spills, appropriate control is possible when some control such as suppressing loop reduction and executing only loop unrolling is necessary. In addition, for example, when loop reduction and software pipelining are expected to be executed at the same time, the performance may decrease rather than the simultaneous operation.
Control that prioritizes reduction is also possible.

【0082】3.例えば,ループ・アンローリング,ル
ープ・リダクションが実施されうるループにおいて,同
時に動作させる場合にアンローリングの数を制限すると
いうような制御が可能になる。
3. For example, in a loop in which loop unrolling and loop reduction can be performed, it becomes possible to perform control such as limiting the number of unrolling when operating simultaneously.

【0083】4.今までのアンローリング数の決定は,
種々の最適化が実施される前のループ内部の変数の依存
関係を解析するため,最適コードを生成するのには限界
があった。これに対し,ループ内変数の依存関係から実
施できる最適化を予想し,その上でその最適化が行われ
た後のループ内で使用される変数の依存関係を把握して
使用レジスタ数を見積もることによりアンローリング数
を決定することが可能になる。
4. The determination of the unrolling number up to now is
There is a limit to the generation of optimal code because it analyzes the dependency relationships of variables inside the loop before various optimizations are performed. On the other hand, we predict the optimization that can be performed from the dependency of the variables in the loop, and then grasp the dependency of the variables used in the loop after the optimization and estimate the number of registers used. This makes it possible to determine the unrolling number.

【0084】5.例えば,高いオプティマイズレベルを
要求された場合は,翻訳時間よりロードモジュールの実
行時間を優先するためにできるだけ多くの情報を獲得し
ておき,低いオプティマイズレベルを要求された場合
は,翻訳時間を優先させるため,取得に時間のかからな
い情報のみを獲得するということが可能になる。
5. For example, when a high optimization level is requested, as much information as possible is acquired to prioritize the execution time of the load module over the translation time, and when a low optimization level is requested, the translation time is prioritized. Therefore, it is possible to acquire only the information that does not take much time to acquire.

【0085】上記項目の実現により,任意のプログラ
ム,任意のハードウェアに対して,どの最適化をどのよ
うに実施したら並列効果の高いコードを生成できるのか
をコンパイラ自身が把握できるようになる。
By implementing the above items, the compiler itself can understand how to perform optimization for any program and any hardware to generate a code having a high parallel effect.

【0086】また,本発明の一つであるループ・リダク
ションは,ループ中に他の演算と依存関係のない変数Q
が,Q=Q+α(αは定数でない)という形で出現し,
かつアンローリングが行われた場合に施されるループ変
形法であり,その並列化効果は非常に高い。
In addition, the loop reduction which is one of the present invention uses the variable Q which has no dependency on other operations in the loop.
Appears in the form Q = Q + α (α is not a constant),
Moreover, it is a loop transformation method that is applied when unrolling is performed, and its parallelization effect is extremely high.

【0087】[0087]

【発明の効果】以上説明したように,従来は最適化同士
が互いに干渉していなかったため,複数の最適化が同時
に動作するとかえって逆効果になる場合があったが,本
発明によれば,各最適化がループ内構造を解析すること
によって予想され,その最適化の実施を考慮に入れたル
ープ内レジスタ数の見積りができ,また,実施予想され
た最適化が互いに干渉しあうことによって,最適化の効
果が最大になるように種々の最適化を実施/抑止するこ
とができるようになり,ループに対してより最適なコー
ドが生成できるようになる。さらに,オプション情報解
析部,ハードウェア情報解析部,プログラム解析部,ル
ープ最適化制御決定部の連係を良くすることによって,
任意のマシン,任意のプログラムでより最適なコードを
生成できるようになる。
As described above, since the optimizations do not interfere with each other in the related art, there are cases where a plurality of optimizations operate at the same time, but rather the opposite effect occurs. However, according to the present invention, Optimization can be predicted by analyzing the structure in the loop, and the number of registers in the loop can be estimated in consideration of the execution of the optimization. Moreover, the optimizations that are expected to be executed interfere with each other to optimize the optimization. Various optimizations can be implemented / suppressed to maximize the effect of optimization, and more optimal code can be generated for loops. Furthermore, by improving the linkage between the option information analysis unit, the hardware information analysis unit, the program analysis unit, and the loop optimization control decision unit,
You can generate more optimal code on any machine and any program.

【0088】ループ・リダクションの効果自体も大き
く,ループ・リダクションが行われるときのループ内の
演算の並列度が高くなるため実行性能は大きく向上す
る。
The effect itself of the loop reduction is also great, and the parallelism of the operations in the loop when the loop reduction is performed becomes high, so that the execution performance is greatly improved.

【図面の簡単な説明】[Brief description of drawings]

【図1】本発明の原理説明図である。FIG. 1 is a diagram illustrating the principle of the present invention.

【図2】本発明に係るループ・リダクションの例の説明
図である。
FIG. 2 is an explanatory diagram of an example of loop reduction according to the present invention.

【図3】本発明の実施例によるループ最適化部の処理フ
ローチャートである。
FIG. 3 is a processing flowchart of a loop optimizing unit according to an embodiment of the present invention.

【図4】本発明の実施例による最適化の例を示す図であ
る。
FIG. 4 is a diagram showing an example of optimization according to an embodiment of the present invention.

【図5】本発明の実施例によるループ最適化部の動作例
の説明図である。
FIG. 5 is an explanatory diagram of an operation example of the loop optimizing unit according to the embodiment of the present invention.

【図6】本発明の実施例において用いられるテーブルの
例を示す図である。
FIG. 6 is a diagram showing an example of a table used in an embodiment of the present invention.

【図7】本発明の実施例において用いられるテーブルの
例を示す図である。
FIG. 7 is a diagram showing an example of a table used in an embodiment of the present invention.

【図8】本発明の実施例におけるアンローリング数のチ
ューニング値を返す関数FUNCの処理説明図である。
FIG. 8 is a process explanatory diagram of a function FUNC that returns a tuning value of the unrolling number according to the embodiment of this invention.

【図9】従来のループ・アンローリングによる最適化の
例の説明図である。
FIG. 9 is an explanatory diagram of an example of optimization by conventional loop unrolling.

【図10】従来のリネーミングによる最適化の例の説明
図である。
FIG. 10 is an explanatory diagram of an example of optimization by conventional renaming.

【図11】従来のソフトウェア・パイプライニングによ
る最適化の例の説明図である。
FIG. 11 is an explanatory diagram of an example of optimization by conventional software pipelining.

【図12】従来のソフトウェア・パイプライニングによ
る最適化の例の説明図である。
FIG. 12 is an explanatory diagram of an example of optimization by conventional software pipelining.

【符号の説明】[Explanation of symbols]

10 処理装置 11 コンパイラ 12 フロントエンド部 13 プログラム構造解析部 14 ループ最適化部 15 レジスタ割り付け部 16 命令スケジューリング部 17 コード生成部 20 ループ最適化制御部 21 オプション情報解析部 22 ハードウェア情報解析部 23 プログラム解析部 24 ループ最適化制御決定部 30 ループ変形部 10 processing device 11 compiler 12 front end unit 13 program structure analysis unit 14 loop optimization unit 15 register allocation unit 16 instruction scheduling unit 17 code generation unit 20 loop optimization control unit 21 option information analysis unit 22 hardware information analysis unit 23 program Analysis unit 24 Loop optimization control determination unit 30 Loop transformation unit

───────────────────────────────────────────────────── フロントページの続き (72)発明者 駒形 真 神奈川県川崎市中原区上小田中1015番地 富士通株式会社内 ─────────────────────────────────────────────────── ─── Continuation of the front page (72) Inventor Shin Komagata 1015 Kamiodanaka, Nakahara-ku, Kawasaki City, Kanagawa Prefecture Fujitsu Limited

Claims (8)

【特許請求の範囲】[Claims] 【請求項1】 ソースプログラムを解析し,最適化処
理,レジスタ割り付け処理,命令スケジューリング,コ
ード出力によってオブジェクトプログラムを出力するコ
ンパイラ装置において,プログラム/ハードウェアの特
性を解析し,同時に動作してはいけない,あるいは同時
に動作するためには制限を加える必要のある最適化群を
認識し,複数の最適化項目に対するループ最適化を統括
的に制御するループ最適化制御部と,このループ最適化
制御部の情報をもとに,個々のループ最適化を実施する
ループ変形部とを備えたことを特徴とするコンパイラ装
置。
1. A compiler apparatus that analyzes a source program and outputs an object program by optimizing processing, register allocation processing, instruction scheduling, and code output, analyzes the characteristics of the program / hardware, and must not operate simultaneously. , Or a loop optimization control unit that recognizes an optimization group that needs to be restricted in order to operate at the same time, and controls the loop optimization for a plurality of optimization items in an integrated manner. A compiler device comprising: a loop transformation unit that performs individual loop optimization based on information.
【請求項2】 ソースプログラムを解析し,最適化処
理,レジスタ割り付け処理,命令スケジューリング,コ
ード出力によってオブジェクトプログラムを出力するコ
ンパイラ装置におけるループ最適化制御方法において,
プログラム/ハードウェアの特性を解析する過程と,解
析結果に基づいて,同時に動作してはいけない,あるい
は同時に動作するためには制限を加える必要のある最適
化群を認識することにより,複数の最適化項目について
それぞれ実施するかしないかを決定し,また実施する場
合における実施条件および最適化の実施順序を決定する
過程と,実施する最適化項目について決定された実施順
序および実施条件に従ってループ最適化を行う過程とを
有することを特徴とするループ最適化制御方法。
2. A loop optimization control method in a compiler apparatus for analyzing a source program and outputting an object program by optimization processing, register allocation processing, instruction scheduling, and code output,
By analyzing the characteristics of the program / hardware and recognizing the optimization group that must not be operated at the same time or must be restricted in order to operate at the same time based on the analysis result, multiple optimizations can be performed. A process of deciding whether or not to implement each optimization item, and determining the implementation condition and the optimization execution sequence when performing it, and the loop optimization according to the implementation order and the implementation condition determined for the optimization item to be implemented. And a loop optimization control method.
【請求項3】 請求項2記載のループ最適化制御方法に
おいて,前記プログラム/ハードウェアの特性を解析す
る過程では,各演算の実行時間の重み付きでカウントさ
れたループ内演算数,ループを変形する最適化の実施予
想,ループ最適化を施した後のループ内で使用されるレ
ジスタの見積り数をプログラム解析情報として,指定さ
れたオプティマイズレベルに依存してプログラム解析レ
ベルを変動させることを特徴とするループ最適化制御方
法。
3. The loop optimization control method according to claim 2, wherein in the process of analyzing the characteristics of the program / hardware, the number of operations in the loop counted by weighting the execution time of each operation and the loop are modified. It is characterized by varying the program analysis level depending on the specified optimization level, using the estimated execution count of the optimization, the estimated number of registers used in the loop after the loop optimization as the program analysis information. Loop optimization control method.
【請求項4】 請求項3記載のループ最適化制御方法に
おいて,ループ内で使用される変数の依存関係を解析
し,その情報から,実際にループ変形を行う時と同じ条
件で,各最適化が実施可能であるかどうかを判定するこ
とを特徴とするループ最適化制御方法。
4. The loop optimization control method according to claim 3, wherein the dependence relationship of variables used in the loop is analyzed, and from this information, each optimization is performed under the same conditions as when actually performing the loop deformation. A loop optimization control method characterized by determining whether or not is possible.
【請求項5】 請求項4記載のループ最適化制御方法に
おいて,最適化予想結果を加味して,ループ変形後にお
けるループ内で使用されるレジスタ数を見積もり,その
レジスタ数から算出したアンローリング数と,ループ内
の各演算の実行時間の重みを加味した総演算数から算出
したアンローリング数と,最適化の予想とに基づいてア
ンローリング数を決定することを特徴とするループ最適
化制御方法。
5. The loop optimization control method according to claim 4, wherein the number of registers used in the loop after the loop deformation is estimated by taking into consideration the optimization prediction result, and the unrolling number calculated from the number of registers. And a loop optimizing control method characterized by determining the unrolling number based on the unrolling number calculated from the total number of operations taking into account the execution time weight of each operation in the loop and the prediction of optimization. .
【請求項6】 請求項5記載のループ最適化制御方法に
おいて,ソフトウェア・パイプライニングが予想された
時のアンローリング数がターゲットであるマシンの浮動
小数点型の除算を除く四則演算中の最大実行時間の倍数
であること,かつ,前記算出された見積りレジスタ数を
考慮したアンローリング数以下であることを満足するア
ンローリング数にすることを特徴とするループ最適化制
御方法。
6. The loop optimization control method according to claim 5, wherein the maximum execution time during the four arithmetic operations excluding the floating-point division of the machine whose unrolling number when the software pipelining is expected is the target. And a non-rolling number that satisfies the calculated estimated number of registers and is equal to or less than the unrolling number.
【請求項7】 ソースプログラムを解析し,最適化処
理,レジスタ割り付け処理,命令スケジューリング,コ
ード出力によってオブジェクトプログラムを出力するコ
ンパイラ装置におけるループ最適化制御方法において,
ループ内の他の演算に定義も参照も現れない変数が定義
オペランドと参照オペランドに現れる演算のアンローリ
ングに対して,その定義オペランドと参照オペランドの
変数名を新しい変数名に置き換え,ループ外でその補正
処理を施すことによりループ内の演算の並列度を高める
ループ変形を行うことを特徴とするループ最適化制御方
法。
7. A loop optimization control method in a compiler apparatus for analyzing a source program and outputting an object program by optimization processing, register allocation processing, instruction scheduling, and code output,
For unrolling of an operation in which a definition or reference does not appear in another operation in the loop in the definition operand and the reference operand, replace the variable name of the definition operand and the reference operand with a new variable name, and A loop optimization control method characterized by performing a loop transformation for increasing the parallelism of operations in a loop by performing a correction process.
【請求項8】 請求項2記載のループ最適化制御方法に
おいて,前記複数の最適化項目に,ループ・アンローリ
ングによるループ変形と,ループ内の他の演算に定義も
参照も現れない変数が定義オペランドと参照オペランド
に現れる演算のアンローリングに対して,その定義オペ
ランドと参照オペランドの変数名を新しい変数名に置き
換え,ループ外でその補正処理を施すことによりループ
内の演算の並列度を高めるループ変形とが含まれること
を特徴とするループ最適化制御方法。
8. The loop optimization control method according to claim 2, wherein the plurality of optimization items define a loop deformation due to loop unrolling, and a variable that does not appear in any other operation in the loop. A loop that increases the parallelism of the operations in the loop by replacing the variable names of the definition operand and the reference operand with new variable names for the unrolling of the operations that appear in the operand and the reference operand, and performing the correction processing outside the loop. A loop optimization control method characterized by including transformations.
JP23667094A 1994-09-30 1994-09-30 Compiler device and loop optimization control method Expired - Fee Related JP3544397B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP23667094A JP3544397B2 (en) 1994-09-30 1994-09-30 Compiler device and loop optimization control method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP23667094A JP3544397B2 (en) 1994-09-30 1994-09-30 Compiler device and loop optimization control method

Publications (2)

Publication Number Publication Date
JPH08101776A true JPH08101776A (en) 1996-04-16
JP3544397B2 JP3544397B2 (en) 2004-07-21

Family

ID=17004049

Family Applications (1)

Application Number Title Priority Date Filing Date
JP23667094A Expired - Fee Related JP3544397B2 (en) 1994-09-30 1994-09-30 Compiler device and loop optimization control method

Country Status (1)

Country Link
JP (1) JP3544397B2 (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2006114069A (en) * 2006-01-20 2006-04-27 Matsushita Electric Ind Co Ltd Compiler device
US7698696B2 (en) 2002-07-03 2010-04-13 Panasonic Corporation Compiler apparatus with flexible optimization
JP2015191346A (en) * 2014-03-27 2015-11-02 富士通株式会社 Compile program, compile method, and compile device
US11579853B2 (en) 2021-03-15 2023-02-14 Fujitsu Limited Information processing apparatus, computer-readable recording medium storing compiling program, and compiling method

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7698696B2 (en) 2002-07-03 2010-04-13 Panasonic Corporation Compiler apparatus with flexible optimization
US8418157B2 (en) 2002-07-03 2013-04-09 Panasonic Corporation Compiler apparatus with flexible optimization
JP2006114069A (en) * 2006-01-20 2006-04-27 Matsushita Electric Ind Co Ltd Compiler device
JP2015191346A (en) * 2014-03-27 2015-11-02 富士通株式会社 Compile program, compile method, and compile device
US9195444B2 (en) 2014-03-27 2015-11-24 Fujitsu Limited Compiler method and compiler apparatus for optimizing a code by transforming a code to another code including a parallel processing instruction
US11579853B2 (en) 2021-03-15 2023-02-14 Fujitsu Limited Information processing apparatus, computer-readable recording medium storing compiling program, and compiling method

Also Published As

Publication number Publication date
JP3544397B2 (en) 2004-07-21

Similar Documents

Publication Publication Date Title
US7448031B2 (en) Methods and apparatus to compile a software program to manage parallel μcaches
Llosa et al. Swing module scheduling: a lifetime-sensitive approach
Rau Iterative modulo scheduling: An algorithm for software pipelining loops
US6754893B2 (en) Method for collapsing the prolog and epilog of software pipelined loops
US5797013A (en) Intelligent loop unrolling
Lilja Exploiting the parallelism available in loops
US8752036B2 (en) Throughput-aware software pipelining for highly multi-threaded systems
JP3311462B2 (en) Compile processing unit
WO1999000731A1 (en) Method for compiling high level programming languages
WO2000063775A1 (en) Dynamic code motion optimization and path tracing
Tang et al. A compiler directed approach to hiding configuration latency in chameleon processors
US5524242A (en) System and method for determining the number of parallel processes to be created according to run cost value and parallelization overhead
Novack et al. Mutation scheduling: A unified approach to compiling for fine-grain parallelism
Sánchez et al. The effectiveness of loop unrolling for modulo scheduling in clustered VLIW architectures
Chen et al. Shared reconfigurable fabric for multi-core customization
Gong et al. HAWS: Accelerating GPU wavefront execution through selective out-of-order execution
August et al. The program decision logic approach to predicated execution
JPH08101776A (en) Compiler device and loop optimizing control method
Larsen et al. Exploiting vector parallelism in software pipelined loops
Abraham et al. Efficient backtracking instruction schedulers
JP3311381B2 (en) Instruction scheduling method in compiler
US6678796B1 (en) System and method for scheduling memory instructions to provide adequate prefetch latency
Ji Ilp-m conv: Optimize convolution algorithm for single-image convolution neural network inference on mobile gpus
US20070074186A1 (en) Method and system for performing reassociation in software loops
Xue et al. Effective loop partitioning and scheduling under memory and register dual constraints

Legal Events

Date Code Title Description
A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20031224

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20040210

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: 20040330

A61 First payment of annual fees (during grant procedure)

Effective date: 20040402

Free format text: JAPANESE INTERMEDIATE CODE: A61

R150 Certificate of patent (=grant) or registration of utility model

Free format text: JAPANESE INTERMEDIATE CODE: R150

FPAY Renewal fee payment (prs date is renewal date of database)

Year of fee payment: 4

Free format text: PAYMENT UNTIL: 20080416

FPAY Renewal fee payment (prs date is renewal date of database)

Year of fee payment: 5

Free format text: PAYMENT UNTIL: 20090416

FPAY Renewal fee payment (prs date is renewal date of database)

Year of fee payment: 5

Free format text: PAYMENT UNTIL: 20090416

FPAY Renewal fee payment (prs date is renewal date of database)

Free format text: PAYMENT UNTIL: 20100416

Year of fee payment: 6

FPAY Renewal fee payment (prs date is renewal date of database)

Year of fee payment: 7

Free format text: PAYMENT UNTIL: 20110416

LAPS Cancellation because of no payment of annual fees