JPH07141196A - Loop developing system having out-of-loop branch - Google Patents

Loop developing system having out-of-loop branch

Info

Publication number
JPH07141196A
JPH07141196A JP5156468A JP15646893A JPH07141196A JP H07141196 A JPH07141196 A JP H07141196A JP 5156468 A JP5156468 A JP 5156468A JP 15646893 A JP15646893 A JP 15646893A JP H07141196 A JPH07141196 A JP H07141196A
Authority
JP
Japan
Prior art keywords
loop
unrolling
branch
intermediate code
flow graph
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.)
Withdrawn
Application number
JP5156468A
Other languages
Japanese (ja)
Inventor
Iwao Nishimura
巌 西村
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.)
HOKKAIDO NIPPON DENKI SOFTWARE KK
NEC Solution Innovators Ltd
Original Assignee
HOKKAIDO NIPPON DENKI SOFTWARE KK
NEC Software Hokkaido 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 HOKKAIDO NIPPON DENKI SOFTWARE KK, NEC Software Hokkaido Ltd filed Critical HOKKAIDO NIPPON DENKI SOFTWARE KK
Priority to JP5156468A priority Critical patent/JPH07141196A/en
Publication of JPH07141196A publication Critical patent/JPH07141196A/en
Withdrawn legal-status Critical Current

Links

Abstract

PURPOSE:To reduce judging frequency at the time of judging whether a loop is to be repeatedly executed or not and to improve the execution performance of a program by executing loop development as for as possible even when the loop is branched from the inside to the outside. CONSTITUTION:A compiler front-ent 2 inputs a source program 1 and outputs an intermediate code 3. An optimizing phase 4 inputs an intermediate code 3 and prepares a flow graph 5, a label table 9 and loop counter information 10. A loop analyzing means 6 in the phase 4 analyzes the flow graph 5 and detects a loop having its branch on the outside of the loop. A loop development judging means 7 in the phase 4 judges the existence of a side effect that the number of reference blocks is increased or compiling time is influenced at the time of practically developing a block 2 out of the loop detected by the means 6 and determines the number of developments. When there are many reference blocks in a procedure, the loop is not developed.

Description

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

【0001】[0001]

【産業上の利用分野】本発明はコンパイラシステムの最
適化方式に関し、特に中間コードによるループ外分岐を
持つループの展開方式に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to an optimizing method for a compiler system, and more particularly to an unrolling method for a loop having a loop outside branch by an intermediate code.

【0002】[0002]

【従来の技術】従来のコンパイラシステムの最適化処理
方式では、ループ展開はループ内からループ外への分岐
のないループに対してのみ行っている。
2. Description of the Related Art In the conventional optimization processing method of a compiler system, loop unrolling is performed only for a loop having no branch from inside the loop to outside the loop.

【0003】[0003]

【発明が解決しようとする課題】上述した従来のループ
展開方式では、ループ内からループ外に分岐がある場合
はループ展開を行わないので、実行時にループ外の分岐
に飛ばない場合、ループを繰返すかどうかの判定部分の
実行に時間がかかるという欠点がある。
In the above-described conventional loop unrolling method, loop unrolling is not performed when there is a branch from inside the loop to outside the loop. Therefore, if the branch outside the loop is not jumped at the time of execution, the loop is repeated. There is a drawback in that it takes time to execute the part for determining whether or not.

【0004】本発明の目的は、上記欠点を解消するため
にループ内からループ外への分岐がある場合でも可能な
限りループ展開を行うループ外分岐を持つループの展開
方式を提供することにある。
SUMMARY OF THE INVENTION It is an object of the present invention to provide a loop unrolling method having an out-of-loop branch that performs loop unrolling as much as possible even when there is a branch from inside the loop to outside the loop in order to solve the above-mentioned drawbacks. .

【0005】[0005]

【課題を解決するための手段】本発明のループ外分岐を
持つループの展開方式は、中間コードを入力情報とする
コンパイラシステムの最適化フェーズにおいて、入力さ
れた中間コードをもとに作られたフローグラフを解析し
てループ外に分岐があるループをみつけだすループ解析
手段と、このループ解析手段によりみつけだされたルー
プをループ展開した場合のコンパイラ時間に与える影響
度を判定してループ展開の可否を判定するループ展開判
定手段と、このループ展開判定手段によりループ展開可
能とされたループに対して展開した結果生成される基本
ブロック内のジャンプ命令の分岐先であるラベルの既存
ラベルとの重複を避けてラベルテーブルを更新し、ルー
プ外へ分岐した時点でのループカウンタの値を保証する
ためのループカウンタ情報を格納して、ラベルテーブル
とループカウンタ情報とをもとにループ展開を行なうル
ープ展開実行手段とを有することにより構成される。
A loop unrolling method having an out-of-loop branch of the present invention is created based on the input intermediate code in the optimization phase of the compiler system using the intermediate code as input information. Whether or not loop unrolling is possible by analyzing the flow graph to find a loop with a branch outside the loop, and the degree of influence on the compiler time when loop unrolling the loop found by this loop analyzer And the existing label of the branch destination of the jump instruction in the basic block generated as a result of the expansion of the loop that can be expanded by this loop expansion determination means. Avoid the loop table to update the label table and guarantee the value of the loop counter at the time of branching out of the loop. Store data information, and by having a loop unrolling execution means for performing loop unrolling on the basis of the label table and the loop counter information.

【0006】[0006]

【実施例】次に、本発明について図面を参照して説明す
る。
DESCRIPTION OF THE PREFERRED EMBODIMENTS Next, the present invention will be described with reference to the drawings.

【0007】図1は本発明の一実施例の構成図である。
図1の実施例は原始プログラム1と、原始プログラム1
を翻訳するコンパイラフロントエンド2と、コンパイラ
フロントエンド2から出力される中間コード3と、中間
コード3を入力することにより作られるフローグラフ
5,展開された結果生成される基本ブロック内のジャン
プ命令の飛び先であるラベルの既存ラベルとの重複を避
けるための情報を格納するラベルテーブル9およびルー
プカウンタとなる変数の情報を保持しているループカウ
ンタ情報10,フローグラフ5を解析することによりル
ープ内からループ外に分岐があってもループ展開の対象
となるループをみつけだすループ解析手段6,ループ展
開の対象となるループに対してループ展開の可・不可を
決定するループ展開判定手段7,および実際にループの
展開を行うループ展開実行手段8を有する最適化フェー
ズ4と、最適化フェーズ4の出力である最適化後の中間
コード11と、中間コード11を入力しオブジェクト1
3を作成するコード生成フェーズ12とから構成され
る。
FIG. 1 is a block diagram of an embodiment of the present invention.
In the embodiment shown in FIG. 1, the source program 1 and the source program 1
A compiler front end 2 for translating the intermediate code 3, an intermediate code 3 output from the compiler front end 2, a flow graph 5 created by inputting the intermediate code 3, and a jump instruction in a basic block generated as a result of expansion. By analyzing the label table 9 that stores information for avoiding duplication of the label that is the jump destination and the existing label, the loop counter information 10 that holds the information of the variable that becomes the loop counter, and the flow graph 5, Even if there is a branch outside the loop, the loop analysis means for finding the loop to be the target of the loop expansion 6, the loop expansion determination means 7 for determining whether the loop to be the target of the loop expansion is enabled or disabled, and the actual An optimization phase 4 having a loop unrolling execution means 8 for unrolling loops, The intermediate code 11 after the optimization is the output of FIG. 4, enter the intermediate code 11 objects 1
3 and a code generation phase 12 for creating the code No.3.

【0008】次にこのように構成された本実施例のルー
プ外分岐を持つループの展開方式の動作について説明す
る。コンパイラフロントエンド2は原始プログラム1を
入力し、中間コード3を出力する。最適化フェーズ4で
は、まず中間コード3を入力し、フローグラフ5,ラベ
ルテーブル9,およびループカウンタ情報10を作成す
る。図4は最適化フェーズ4に入力された中間コード3
から作られるラベルテーブル9の一例を示す図である。
最適化フェーズ4は、中間コード3の最初に現れた分岐
先のラベルより大きいラベルに対してはleftに、小
さいラベルに対してはrightに新しくテーブルを追
加することによりラベルテーブルを作成する。
Next, the operation of the loop unrolling system having the branch outside the loop of the present embodiment configured as described above will be described. The compiler front end 2 inputs the source program 1 and outputs intermediate code 3. In the optimization phase 4, first, the intermediate code 3 is input, and the flow graph 5, the label table 9, and the loop counter information 10 are created. FIG. 4 shows the intermediate code 3 input in the optimization phase 4.
It is a figure which shows an example of the label table 9 made from.
In the optimization phase 4, a label table is created by newly adding a table to left for a label larger than the branch destination label appearing at the beginning of the intermediate code 3 and right for a smaller label.

【0009】最適化フェーズ4におけるループ解析手段
6は、フローグラフ5を解析して、ループ外に分岐のあ
るループをみつけだす。図2は展開前のフローグラフの
一例を示す図である。図2でblock1からbloc
k5は基本ブロックを示し、ループはblock2,b
lock4で構成される。またこの例で、ループ解析手
段6で調べるループ展開の判定条件は、a)block
2の条件分岐の先がblock4、b)block4の
条件分岐の先がblock2、c)block2の直前
の分岐ブロックがblock4の三つを満たす場合であ
る。
The loop analysis means 6 in the optimization phase 4 analyzes the flow graph 5 and finds a loop having a branch outside the loop. FIG. 2 is a diagram showing an example of a flow graph before expansion. In Figure 2, block1 to block
k5 indicates a basic block, and the loop is block2, b
It is composed of lock4. Further, in this example, the loop unrolling determination condition checked by the loop analysis means 6 is a) block.
This is a case where the destination of the second conditional branch is block4, the destination of the b) block4 conditional branch is block2, and the immediately preceding branch block of the c) block2 satisfies block4.

【0010】最適化フェーズ4におけるループ展開判定
手段7はループ解析手段6でみつけたループのうちbl
ock2に対して、実際に展開を行った場合に基本ブロ
ック数が多くなり、コンパイル時間に影響を与えるとい
う副作用がないかを判定して展開数を決定する。なお、
副作用がないと判定したとき実施例では展開数は4とす
るが、手続き内の基本ブロック数が多いときはループの
展開は行わない。
The loop unrolling decision means 7 in the optimization phase 4 is bl among the loops found by the loop analysis means 6.
The number of basic blocks is increased when ock2 is actually expanded, and the number of expansions is determined by determining whether or not there is a side effect of affecting the compile time. In addition,
When it is determined that there is no side effect, the number of expansions is set to 4 in the embodiment, but when the number of basic blocks in the procedure is large, the expansion of the loop is not performed.

【0011】最適化フェーズ4におけるループ展開実行
手段8によりループの展開を行うときは、ラベルテーブ
ル9のleftのチェインをたどり、分岐先がない(n
il)ならそこに前のテーブルより一つ大きいラベルを
持つテーブルを追加することによりラベルテーブルを更
新する。また、最適化フェーズ4はループカウンタ情報
10にループカウンタとなる変数の情報を格納する。
When the loop unrolling execution means 8 in the optimization phase 4 unrolls the loop, the chain of lefts in the label table 9 is followed and there is no branch destination (n
il), update the label table by adding to it a table with a label one greater than the previous table. In the optimization phase 4, the loop counter information 10 stores the information of the variable that becomes the loop counter.

【0012】ループ展開実行手段8ではラベルテーブル
9とループカウンタ情報10をもとにblock2に対
して、4段に展開を行う。図3はループ展開実行手段8
により更新されたフローグラフのイメージを示す図であ
る。ここでは、block2とは異なるラベルを持ち、
ループカウンタを1増加させる基本ブロックを三つ追加
することにより4段にループの展開をしたことになる。
The loop unrolling execution means 8 unrolls block 2 into four stages based on the label table 9 and the loop counter information 10. FIG. 3 shows loop unrolling execution means 8
It is a figure which shows the image of the flow graph updated by. Here, it has a label different from block2,
By adding three basic blocks that increase the loop counter by 1, the loop is expanded into four stages.

【0013】最適化フェーズ4は各種の最適化を行った
後、更新されたフローグラフを解析し、最適化後の中間
コード11を出力する。最後に最適化後の中間コード1
1をコード生成フェーズ12に入力しオブジェクト13
を作成する。
In the optimization phase 4, after performing various optimizations, the updated flow graph is analyzed and the optimized intermediate code 11 is output. Finally, the intermediate code after optimization 1
1 is input to the code generation phase 12 and the object 13
To create.

【0014】[0014]

【発明の効果】以上に説明したように本発明は、ループ
外に分岐があってもループ展開ができるため、ループを
繰返すかどうかの実行時での判定回数が減少することか
ら、プログラムの実行性能を向上させる効果がある。
As described above, according to the present invention, even if there is a branch outside the loop, the loop expansion can be performed, so that the number of times of determining whether or not to repeat the loop at the time of execution is reduced. It has the effect of improving performance.

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

【図1】本発明の一実施例の構成図である。FIG. 1 is a configuration diagram of an embodiment of the present invention.

【図2】図1における展開前のフローグラフの一例を示
す図である。
FIG. 2 is a diagram showing an example of a flow graph before expansion in FIG.

【図3】図1における展開後のフローグラフの一例を示
す図である。
FIG. 3 is a diagram showing an example of a flow graph after expansion in FIG.

【図4】図1のラベルテーブルの一例を示す図である。FIG. 4 is a diagram showing an example of a label table of FIG.

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

1 原始プログラム 2 コンパイラフロントエンド 3 中間コード 4 最適化フェーズ 5 フローグラフ 6 ループ解析手段 7 ループ展開判定手段 8 ループ展開実行手段 9 ラベルテーブル 10 ループカウンタ情報 11 最適化後の中間コード 12 コード生成フェーズ 13 オブジェクトファイル DESCRIPTION OF SYMBOLS 1 source program 2 compiler front end 3 intermediate code 4 optimization phase 5 flow graph 6 loop analysis means 7 loop unrolling determination means 8 loop unrolling execution means 9 label table 10 loop counter information 11 intermediate code after optimization 12 code generation phase 13 Object file

Claims (1)

【特許請求の範囲】[Claims] 【請求項1】 中間コードを入力情報とするコンパイラ
システムの最適化フェーズにおいて、入力された中間コ
ードをもとに作られたフローグラフを解析してループ外
に分岐があるループをみつけだすループ解析手段と、こ
のループ解析手段によりみつけだされたループをループ
展開した場合のコンパイラ時間に与える影響度を判定し
てループ展開の可否を判定するループ展開判定手段と、
このループ展開判定手段によりループ展開可能とされた
ループに対して展開した結果生成される基本ブロック内
のジャンプ命令の分岐先であるラベルの既存ラベルとの
重複を避けてラベルテーブルを更新し、ループ外へ分岐
した時点でのループカウンタの値を保証するためのルー
プカウンタ情報を格納して、ラベルテーブルとループカ
ウンタ情報とをもとにループ展開を行なうループ展開実
行手段とを有することを特徴とするループ外分岐を持つ
ループの展開方式。
1. A loop analyzing means for finding a loop having a branch outside the loop by analyzing a flow graph created based on the input intermediate code in an optimization phase of a compiler system using the intermediate code as input information. And a loop unrolling determination unit that determines whether loop unrolling is possible by determining the degree of influence on the compiler time when the loop found by this loop analysis unit is loop unrolled,
The label table is updated by avoiding the overlap with the existing label of the branch destination of the jump instruction in the basic block generated as a result of unrolling the loop that can be loop unrolled by the loop unrolling determination means, A loop unrolling execution means for storing loop counter information for guaranteeing the value of the loop counter at the time of branching out, and for unrolling the loop based on the label table and the loop counter information. A loop unrolling method that has a branch outside the loop.
JP5156468A 1993-06-28 1993-06-28 Loop developing system having out-of-loop branch Withdrawn JPH07141196A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP5156468A JPH07141196A (en) 1993-06-28 1993-06-28 Loop developing system having out-of-loop branch

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP5156468A JPH07141196A (en) 1993-06-28 1993-06-28 Loop developing system having out-of-loop branch

Publications (1)

Publication Number Publication Date
JPH07141196A true JPH07141196A (en) 1995-06-02

Family

ID=15628411

Family Applications (1)

Application Number Title Priority Date Filing Date
JP5156468A Withdrawn JPH07141196A (en) 1993-06-28 1993-06-28 Loop developing system having out-of-loop branch

Country Status (1)

Country Link
JP (1) JPH07141196A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2020240830A1 (en) * 2019-05-31 2020-12-03 三菱電機株式会社 Detection device, detection method, and detection program

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2020240830A1 (en) * 2019-05-31 2020-12-03 三菱電機株式会社 Detection device, detection method, and detection program
JPWO2020240830A1 (en) * 2019-05-31 2021-10-21 三菱電機株式会社 Detection device, detection method, and detection program

Similar Documents

Publication Publication Date Title
US11216258B2 (en) Direct function call substitution using preprocessor
JPH05257709A (en) Parallelism discriminating method and parallelism supporting method using the same
JP2004038225A (en) Compiler program and compiling method
JPH06314203A (en) Method and device for optimizing compiler
JPH11242597A (en) Method for generation of flow graph of java byte code data
US6519765B1 (en) Method and apparatus for eliminating redundant array range checks in a compiler
US20070277166A1 (en) Method and apparatus for performing versioning for loop, method and apparatus for collecting array range check information in basic blocks, method for modifying array range check information, method for optimizing array range checks, method for generating codes for array range checks, method and apparatus for eliminating redundant array range checks, method for selecting array range checks, method for modifying array range checks, method for collecting array range checks, and method for determining handling of array range checks
EP3152658B1 (en) Data-dependent control flow reduction
US8117604B2 (en) Architecture cloning for power PC processors
Sathyanathan et al. Incremental whole program optimization and compilation
JPH07141196A (en) Loop developing system having out-of-loop branch
JP2001125792A (en) Optimization promoting device
JP3032030B2 (en) Loop optimization method and apparatus
JP2956591B2 (en) Method and apparatus for parallelizing a loop having a conditional jump out of the loop
JPH09282173A (en) Static analysis method for program
JP2008015665A (en) Program analysis method and program analyzer
JPH09160784A (en) Paralleled compiling system
JPH09265400A (en) Compilation optimizing system
JP3367438B2 (en) Conditional execution processing device
JPH11195011A (en) Language translation processor, language translation processing method and record medium recording language translation processing program
JP3018783B2 (en) Compilation method
JPH10326193A (en) Compile method for optimizing inline expansion function
JP3311774B2 (en) Compiler unit
JPH0573335A (en) Automatic in-line development system for program
JP2002323981A (en) Method and device for adjusting number of performance steps of object program, and recording medium with program stored

Legal Events

Date Code Title Description
A300 Application deemed to be withdrawn because no request for examination was validly filed

Free format text: JAPANESE INTERMEDIATE CODE: A300

Effective date: 20000905