JPH0417031A - System for optimizing propagation of constant value - Google Patents

System for optimizing propagation of constant value

Info

Publication number
JPH0417031A
JPH0417031A JP12067390A JP12067390A JPH0417031A JP H0417031 A JPH0417031 A JP H0417031A JP 12067390 A JP12067390 A JP 12067390A JP 12067390 A JP12067390 A JP 12067390A JP H0417031 A JPH0417031 A JP H0417031A
Authority
JP
Japan
Prior art keywords
instruction
constant value
instructions
constant
memory
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.)
Pending
Application number
JP12067390A
Other languages
Japanese (ja)
Inventor
Shigeya Matsuo
篤弥 松尾
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.)
NEC Corp
Original Assignee
NEC Corp
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 NEC Corp filed Critical NEC Corp
Priority to JP12067390A priority Critical patent/JPH0417031A/en
Publication of JPH0417031A publication Critical patent/JPH0417031A/en
Pending legal-status Critical Current

Links

Landscapes

  • Devices For Executing Special Programs (AREA)

Abstract

PURPOSE:To reduce the size of an object program and to increase the executing speed of it by propagating the constant value of an operand to the operands of the following instructions against an instruction within a range in which the control is linearly shifted. CONSTITUTION:A constant value propagating means 3 propagates a constant value among the operands of transferring instructions by analyzing instructions and operands at every instruction block divided by an instruction block dividing means and replaces an transferring instruction or calculating instruction from a register and memory having the same value as the constant value with the transferring instruction of the constant value. An unnecessary instruction deleting means 3 deletes an unnecessary instruction in an instruction block for which instruction replacement is made by means of the means 3 and an instruction output means 5 outputs the instruction train for which constant value propagation and unnecessary instruction deletion optimization are respectively made by the means 3 and 4 to an instruction storing medium 10. Therefore, the reduction of size and increase of executing speed of an object program can be performed.

Description

【発明の詳細な説明】 〔産業上の利用分野〕 本発明は定数値伝播最適化方式に関し、特に−命令の大
きさがすべて同じである命令セットをもったアーキテク
チャ上における機械語命令レベルの最適化を行う定数値
伝播最適化方式に関する。
[Detailed Description of the Invention] [Field of Industrial Application] The present invention relates to a constant value propagation optimization method, and particularly to - optimization at the machine language instruction level on an architecture with an instruction set in which all instructions have the same size. This paper concerns a constant value propagation optimization method that performs optimization.

〔従来の技術〕[Conventional technology]

従来のコンパイラ内部の中間テキストに対して行われる
最適化は、ソースプログラムの記述に依存する部分が多
い。また、ソースプログラムの記述に依存しない機械語
命令レベルの最適化でも、定数の値そのものを意識した
ような最適化はなかった。特に、機械語命令の生成完了
後に機械語命令に対して定数値を伝播して最適化するも
のはなかった。
Optimization performed on intermediate text within conventional compilers largely depends on the source program description. Furthermore, even with optimization at the machine language instruction level that does not depend on the description of the source program, there has been no optimization that takes into account the values of constants themselves. In particular, there has been no optimization method that propagates constant values to machine language instructions after the machine language instructions have been generated.

〔発明が解決しようとする課題〕[Problem to be solved by the invention]

上述した従来の最適化方式では、機械語命令レベルで定
数の値そのものを意識したような最適化は存在しなかっ
たので、生成される機械語命令は必ずしも最適な命令列
ではなく、オブジェクトプログラムのサイズの増大や実
行スピードの低下を招くという欠点がある。
In the conventional optimization method described above, there was no optimization that was conscious of the constant value itself at the machine language instruction level, so the generated machine language instructions are not necessarily the optimal instruction sequence, but are based on the object program. It has the disadvantage of increasing size and decreasing execution speed.

また、複数のコンパイラで同じような最適化処理を実装
しているため、無駄が生じるという欠点がある。
Another drawback is that multiple compilers implement similar optimization processing, resulting in waste.

本発明の目的は、上述の点に鑑み、線形に制御移行する
範囲内の命令に対してオペランドの定数値を命令コード
によって以降の命令のオペランドに伝播していくことに
よってコンパイル時に可能な定数計算を行い、より速い
命令に置き換えたり命令の置換えに伴って不要となる不
要命令(その命令が設定するオペランドが以降で参照さ
れないうちに他の命令によって再び設定される場合の前
者の設定命令)を削除したりして、オブジェクトプログ
ラムのサイズの縮小や実行スピードの短縮を図るように
した定数値伝播最適化方式を提供することにある。
In view of the above-mentioned points, an object of the present invention is to make constant calculation possible at compile time by propagating constant values of operands to operands of subsequent instructions using instruction codes for instructions within the range of linear control transfer. and replace it with a faster instruction, or replace an unnecessary instruction that becomes unnecessary due to instruction replacement (the former setting instruction when the operand set by that instruction is set again by another instruction before it is referenced later). An object of the present invention is to provide a constant value propagation optimization method that reduces the size of an object program and shortens the execution speed by deleting the object program.

〔課題を解決するための手段〕[Means to solve the problem]

本発明の定数値伝播最適化方式は、−命令の大きさがす
べて同じである命令セットをもったアーキテクチャ上に
おいて、命令格納媒体から命令の並びを入力してメモリ
上に展開する命令入力手段と、この命令入力手段により
メモリ上に展開された命令を解析して分岐命令の直後と
分岐先ラベル位置とで命令の並びを分割して命令ブロッ
クを作成する命令ブロック分割手段と、この命令ブロッ
ク分割手段により分割された命令ブロックごとに命令お
よびそのオペランドを解析して移送命令のオペランド間
で定数値を伝播し定数値と同値なレジスタおよびメモリ
からの移送命令を定数値の移送命令に置き換えたり演算
命令の参照オペランドがすべて定数値ならびに定数値と
同値なレジスタおよびメモリの場合に定数演算を行って
演算命令を定数値の移送命令に置き換えたりする定数値
伝播手段と、この定数値伝播手段により命令の置換えが
なされた命令ブロック内の不要命令を削除する不要命令
削除手段と、前記定数値伝播手段による定数値伝播およ
び前記不要命令削除手段による不要命令削除の最適化が
なされた命令列を命令格納媒体に出力する命令出力手段
とを有する。
The constant value propagation optimization method of the present invention provides an instruction input means for inputting a sequence of instructions from an instruction storage medium and expanding them onto memory on an architecture having an instruction set in which all instructions have the same size. , an instruction block dividing means for creating an instruction block by analyzing the instructions expanded on the memory by the instruction input means and dividing the sequence of instructions immediately after the branch instruction and at the branch destination label position, and this instruction block dividing means. Analyzes instructions and their operands for each instruction block divided by means, propagates constant values between operands of transfer instructions, replaces transfer instructions from registers and memory with the same value as the constant value, and performs operations such as replacing transfer instructions with transfer instructions with constant values. A constant value propagation means that performs constant operation and replaces the operation instruction with a transfer instruction of the constant value when all reference operands of an instruction are constant values and registers and memories that are equivalent to the constant values, and this constant value propagation means An unnecessary instruction deletion means for deleting unnecessary instructions in the instruction block in which the instructions have been replaced, and an instruction sequence that has been optimized for constant value propagation by the constant value propagation means and unnecessary instruction deletion by the unnecessary instruction deletion means. and command output means for outputting to a storage medium.

〔作用〕[Effect]

本発明の定数値伝播最適化方式では、命令入力手段が命
令格納媒体から命令の並びを入力してメモリ上に展開し
、命令ブロック分割手段が命令入力手段によりメモリ上
に展開された命令を解析して分岐命令の直後と分岐先ラ
ベル位置とで命令の並びを分割して命令ブロックを作成
し、定数値伝播手段が命令ブロック分割手段により分割
された命令ブロックごとに命令およびそのオペランドを
解析して移送命令のオペランド間で定数値を伝播し定数
値と同値なレジスタおよびメモリからの移送命令を定数
値の移送命令に置き換えたり演算命令の参照オペランド
がすべて定数値ならびに定数値と同値なレジスタおよび
メモリの場合に定数演算を行って演算命令を定数値の移
送命令に置き換えたりし、不要命令削除手段が定数値伝
播手段により命令の置換えがなされた命令ブロック内の
不要命令を削除し、命令出力手段が定数値伝播手段によ
る定数値伝播および不要命令削除手段による不要命令削
除の最適化がなされた命令列を命令格納媒体に出力する
In the constant value propagation optimization method of the present invention, the instruction input means inputs a sequence of instructions from the instruction storage medium and expands it onto the memory, and the instruction block division means analyzes the instructions expanded on the memory by the instruction input means. The instruction block is created by dividing the instruction sequence immediately after the branch instruction and at the branch destination label position, and the constant value propagation means analyzes the instructions and their operands for each instruction block divided by the instruction block division means. propagate constant values between the operands of transfer instructions, and replace transfer instructions from registers and memory with constant values with transfer instructions with constant values; In the case of memory, a constant operation is performed to replace the operation instruction with a constant value transfer instruction, and the unnecessary instruction deletion means deletes the unnecessary instruction in the instruction block in which the instruction has been replaced by the constant value propagation means, and the instruction The output means outputs to the instruction storage medium an instruction sequence that has been optimized for constant value propagation by the constant value propagation means and for unnecessary instruction deletion by the unnecessary instruction deletion means.

〔実施例〕〔Example〕

次に、本発明について図面を参照して詳細に説明する。 Next, the present invention will be explained in detail with reference to the drawings.

第1図は、本発明の一実施例に係る定数値伝播最適化方
式の構成を示すブロック図である。本実施例の定数値伝
播最適化方式は、命令入力手段1と、命令ブロック分割
手段2と、定数値伝播手段3と、不要命令削除手段4と
、命令出力手段5と、命令展開メモリ6と、複数のプロ
ソクテーブル7と、レジスタテーブル8と、メモリテー
ブル9と、ファイル、メモリ等でなり機械語命令レベル
の命令を格納する命令格納媒体IOとから構成されてい
る。
FIG. 1 is a block diagram showing the configuration of a constant value propagation optimization method according to an embodiment of the present invention. The constant value propagation optimization method of this embodiment includes an instruction input means 1, an instruction block division means 2, a constant value propagation means 3, an unnecessary instruction deletion means 4, an instruction output means 5, and an instruction expansion memory 6. , a plurality of prosock tables 7, a register table 8, a memory table 9, and an instruction storage medium IO consisting of files, memories, etc., and storing instructions at the machine language instruction level.

第2図を参照すると、各ブロックテーブル7は、アドレ
ス順次チェーンと命令ポインタとから構成されており、
ブロックテーブル起点ポインタからアドレス順次チェー
ンによってチェーニングされている。各ブロックテーブ
ル7の命令ポインタは、命令展開メモリ6上の命令のア
ドレスまたは命令展開メモリ6上の展開命令内相対オフ
セットでなり、命令展開メモリ6上に展開された命令中
の対応する命令ブロックの先頭アドレスをポイントして
いる。
Referring to FIG. 2, each block table 7 is composed of an address sequential chain and an instruction pointer.
The addresses are chained in sequential order from the block table starting point pointer. The instruction pointer of each block table 7 is the address of the instruction on the instruction expansion memory 6 or the relative offset within the expanded instruction on the instruction expansion memory 6, and is the address of the instruction on the instruction expansion memory 6, or the relative offset within the expanded instruction on the instruction expansion memory 6. It points to the first address.

第3図を参照すると、レジスタテーブル8は、レジスタ
番号と、設定フラグと、定数値とからなる複数のエント
リで構成されている。
Referring to FIG. 3, the register table 8 is composed of a plurality of entries consisting of register numbers, setting flags, and constant values.

第4図を参照すると、メモリテーブル9は、アドレスお
よび長さからなるメモリ情報と、定数値とからなる複数
のエントリで構成されている。
Referring to FIG. 4, the memory table 9 is composed of a plurality of entries consisting of memory information consisting of addresses and lengths and constant values.

次に、このように構成された本実施例の定数値伝播最適
化方式の動作について説明する。
Next, the operation of the constant value propagation optimization method of this embodiment configured as described above will be explained.

まず、命令入力手段1は、命令を格納した任意の命令格
納媒体10から一命令ずつ命令を入力し、命令展開メモ
リ6上に展開した後に命令ブロック分割手段2を呼び出
す。
First, the instruction input means 1 inputs instructions one by one from any instruction storage medium 10 storing instructions, expands them onto the instruction expansion memory 6, and then calls the instruction block division means 2.

命令ブロック分割手段2は、命令コードを解析し、命令
が分岐命令のときのみに命令ブロックの分割処理を行う
。命令ブロックとは、命令の並びの中で制御上の入口が
1つで出口が1つ、かつ途中に出口以外の分岐がないよ
うな単位をいい、分割された命令ブロックは、第2図に
示すように、ブロックテーブル7が命令展開メモリ6中
の命令ブロックの先頭命令を命令ポインタによってポイ
ントすることによって指示される。命令ブロックの分割
処理では、以下の処理2.1および2.2により、分岐
命令の直後と分岐先ラベル位置とで命令ブロックを分割
する。
The instruction block dividing means 2 analyzes the instruction code and performs instruction block dividing processing only when the instruction is a branch instruction. An instruction block is a unit of instructions that has one control entrance, one exit, and no branches other than the exit.The divided instruction block is shown in Figure 2. As shown, the block table 7 is designated by pointing the first instruction of the instruction block in the instruction expansion memory 6 with an instruction pointer. In the instruction block division process, the instruction block is divided immediately after the branch instruction and at the branch destination label position by the following processes 2.1 and 2.2.

処理↓ユ上:分岐命令の直後の命令を命令ポインタがポ
イントするブロックテーブル7をサーチし、すでにあれ
ば何もしない。なければ、ブロックテーブル7を1つ作
成し、分岐命令の直後の命令を命令ブロックの最初の命
令として命令ポインタを設定し、ブロックテーブル7を
命令のアドレス順にチェーニングするようにアドレス順
次チェーンによって直前および直後のブロックテーブル
7とチェーニングする。
Processing↓Upper: Searches the block table 7 where the instruction pointer points to the instruction immediately after the branch instruction, and if it already exists, does nothing. If not, create one block table 7, set the instruction pointer to the instruction immediately after the branch instruction as the first instruction of the instruction block, and use address sequential chaining to chain the block table 7 in the order of the instructions' addresses. Chains with block table 7 immediately after.

処1蛮工I−分岐命令の分岐相対オフセットから分岐先
命令をポイントするブロックテーブル7をサーチし、処
理2.1と同様に、命令のアドレス順に直前および直後
のブロックテーブル7とチェーニングする。
Process 1 - Search the block table 7 pointing to the branch destination instruction from the branch relative offset of the branch instruction, and chain with the immediately preceding and succeeding block tables 7 in the order of the address of the instruction, as in process 2.1.

命令入力手段1と命令ブロック分割手段2との処理を繰
り返し、命令格納媒体10内の全命令について処理が行
われると、命令展開メモリ6上に複数のブロックテーブ
ル7によりブロック分割された命令列が展開される。
When the processing by the instruction input means 1 and the instruction block division means 2 is repeated and all the instructions in the instruction storage medium 10 are processed, the instruction sequence divided into blocks by the plurality of block tables 7 is stored on the instruction expansion memory 6. Be expanded.

次に、定数値伝播手段3は、アドレス順次チェーンに従
ってブロックテーブル7をたどり、線形に制御移行する
命令ブロック内の命令に対してレジスタテーブル8およ
びメモリテーブル9を使用して定数値伝播処理を行う。
Next, the constant value propagation means 3 follows the block table 7 according to the address sequential chain, and uses the register table 8 and the memory table 9 to perform constant value propagation processing on instructions in the instruction block that linearly transfer control. .

定数値伝播手段3は、以下の処理3.1および処理3.
2または3.3のいずれかを繰り返して行う。
The constant value propagation means 3 performs the following process 3.1 and process 3.
Repeat either 2 or 3.3.

113.1ニアドレス順次チェーンに従ってブロックテ
ーブル7をたどり、解析対象の命令ブロックを決める。
113.1 The block table 7 is traced according to the near address sequential chain to determine the instruction block to be analyzed.

解析対象の命令ブロックがなくなったならば、定数値伝
播手段3の処理を終了する。
When there are no more instruction blocks to be analyzed, the processing of the constant value propagation means 3 ends.

解析対象の命令ブロックを決めた時点で、レジスタテー
ブル8の全エントリの設定フラグをオフにし、メモリテ
ーブル9の全エントリを削除する。
Once the instruction block to be analyzed is determined, the setting flags of all entries in the register table 8 are turned off, and all entries in the memory table 9 are deleted.

そして、解析対象の命令ブロックに対して、命令ブロッ
ク内の命令を制御移行順にたどって解析対象の命令を決
め、処理3.2または3.3を繰り返し行う。解析対象
の命令ブロックの処理中に1つでも命令の置換えがなさ
れたならば、その命令ブロック内の全命令に対する処理
3.2または3.3の繰返しが終了した後、不要命令削
除手段4を呼び出す。
Then, for the instruction block to be analyzed, the instructions in the instruction block are traced in the order of control transfer to determine the instruction to be analyzed, and processing 3.2 or 3.3 is repeatedly performed. If even one instruction is replaced during the processing of the instruction block to be analyzed, after completing the repetition of processing 3.2 or 3.3 for all instructions in the instruction block, the unnecessary instruction deletion means 4 is executed. call.

処1ユ↓:解析対象の命令が移送命令の場合、移送元の
オペランドが定数値の情報をもてば、その定数値を移送
先のオペランドに伝播する。移送元のオペランドが定数
値の情報をもたなければ、移送先のオペランドのもって
いる定数値の情報をクリアする。具体的には、レジスタ
テーブル8およびメモリテーブル9を使用して、以下の
ように処理する。
Process 1 Yu↓: When the instruction to be analyzed is a transfer instruction, if the source operand has constant value information, the constant value is propagated to the destination operand. If the source operand does not have constant value information, the constant value information held by the destination operand is cleared. Specifically, the register table 8 and memory table 9 are used to perform the following processing.

■ 移送元のオペランドを分類して、各々以下のように
伝播する定数値Cを求める。
■ Classify the transfer source operands and find the constant value C to be propagated for each as follows.

定数の場合;定数の値Cを求める。In the case of a constant: Find the value C of the constant.

レジスタの場合ニレジスタテ−プル8の該当するエント
リの設定フラグがオンならば、エントリの定数値Cを求
める。
In the case of a register, if the setting flag of the corresponding entry in register table 8 is on, the constant value C of the entry is determined.

メモリの場合:メモリテーブル9に同じメモリ情報をも
つエントリがあれば、そのエントリに設定しである定数
値Cを求める。
In the case of memory: If there is an entry with the same memory information in the memory table 9, the constant value C set in that entry is determined.

■ ■で定数値Cが求められた場合、移送先のオペラン
ドを分類して、各々以下のように定数値Cを伝播する。
(2) When the constant value C is obtained in (2), the destination operands are classified and the constant value C is propagated to each as follows.

レジスタの場合ニレジスタテ−プル8の該当するエント
リの定数値フィールドに定数値Cを設定し、設定フラグ
をオンにする。
In the case of a register, a constant value C is set in the constant value field of the corresponding entry in the second register table 8, and the setting flag is turned on.

メモリの場合:メモリテーブル9のエントリのうちのメ
モリと同じ領域の一部または全部をアクセスする可能性
のあるメモリのエントリを削除する。さらに、メモリテ
ーブル9に同じメモリ情報をもつエントリがあれば、そ
のエントリの定数値フィールドに定数値Cを設定し、な
ければ新しくエントリを追加し、メモリ情報と定数値C
とを設定する。
In the case of memory: Among the entries in the memory table 9, memory entries that may access part or all of the same area as the memory are deleted. Furthermore, if there is an entry with the same memory information in the memory table 9, a constant value C is set in the constant value field of that entry, and if there is not, a new entry is added, and the memory information and constant value C are set.
and set.

■ ■で定数値Cが求められ、かつ移送元のオペランド
が定数でない場合、定数値Cを移送先のオペランドに移
送する命令(定数移送命令と呼ぶ)がアーキテクチャ上
に存在して、かつ元の移送命令と定数移送命令との実行
スピードを比較して後者の方が速ければ、命令展開メモ
リ6内の元の移送命令を定数移送命令に置き換える。
■ If a constant value C is obtained in ■ and the source operand is not a constant, an instruction (called a constant transfer instruction) exists in the architecture that transfers the constant value C to the destination operand, and the source operand is not a constant. Comparing the execution speeds of the transfer instruction and the constant transfer instruction, if the latter is faster, the original transfer instruction in the instruction expansion memory 6 is replaced with the constant transfer instruction.

■ ■で定数値Cが求められなかった場合、移送先のオ
ペランドを分類して、各々以下のように定数の情報をク
リアする。
(2) If constant value C cannot be obtained in (2), the destination operands are classified and the constant information for each is cleared as shown below.

レジスタの場合ニレジスタテ−プル8の該当するエント
リの設定フラグをオフする。
In the case of a register, the setting flag of the corresponding entry in register table 8 is turned off.

メモリの場合:メモリテーブル9に同じメモリ情報をも
つエントリがあれば、そのエントリを削除する。また、
該メモリと同じ領域の一部または全部をアクセスする可
能性のあるメモリのエントリも削除する。
In the case of memory: If there is an entry with the same memory information in the memory table 9, that entry is deleted. Also,
Memory entries that may access part or all of the same area as the memory are also deleted.

処理↓−主:解析対象の命令が演算命令の場合、そのす
べての被演算オペランドが定数値の情報をもっていれば
、定数演算をして解析対象の演算命令を定数演算の結果
の定数から演算結果格納オペランドへの移送命令に置き
換える。その被演算オペランドのいずれかが定数値の情
報をもたなければ、演算結果格納オペランドのもってい
る定数値の情報をクリアする。具体的には、レジスタテ
ーブル8およびメモリテーブル9を使用して、以下のよ
うに処理する。
Processing ↓ - Main: If the instruction to be analyzed is an arithmetic instruction, and all operand operands have constant value information, perform a constant operation and convert the arithmetic instruction to be analyzed to the operation result from the constant that is the result of the constant operation. Replace with a transfer instruction to the storage operand. If any of the operated operands does not have constant value information, the constant value information held by the operation result storage operand is cleared. Specifically, the register table 8 and memory table 9 are used to perform the following processing.

■ 演算命令の被演算オペランドをQpi  (i=1
.2.・・・、nun≧1)とする。被演算オペランド
OPiのすべてが以下の条件1a)〜tc+のいずれか
を満たす場合、定数値Ci  (i=1.2.・・・n
)を演算命令で示される演算によって定数演算し、その
結果を定数値Rとする。
■ The operand of the operation instruction is Qpi (i=1
.. 2. ..., nun≧1). When all of the operands OPi satisfy any of the following conditions 1a) to tc+, the constant value Ci (i=1.2...n
) is subjected to a constant operation by the operation indicated by the operation instruction, and the result is set as a constant value R.

fa)OPiは定数(定数値をCiとする)[blOP
iはレジスタで、かつレジスタテーブル8の該当するエ
ントリの設定フラグがオン(該エントリの定数値をCi
とする) (clOPiはメモリで、かつメモリテーブル9に同じ
メモリ情報をもつエントリがある(該エントリの定数値
をCiとする) ■ ■の条件を満たして定数値Rが求められたならば、
命令展開メモリ6内の解析対象の演算命令を、定数値R
を演算結果格納オペランドに移送する定数移送命令に置
き換える。
fa) OPi is a constant (constant value is Ci) [blOP
i is a register, and the setting flag of the corresponding entry in register table 8 is on (the constant value of the entry is set to Ci
) (clOPi is a memory, and there is an entry with the same memory information in the memory table 9 (the constant value of this entry is Ci) If the constant value R is found by satisfying the conditions of ■ ■, then
The arithmetic instruction to be analyzed in the instruction expansion memory 6 is set to a constant value R.
Replace it with a constant transfer instruction that transfers it to the operation result storage operand.

■ ■の条件を満たして定数値Rが求められたならば、
その演算結果格納オペランドの種類によって、処理3.
2の■の定数値Cを定数値Rに置き換えた処理をする。
■ If the constant value R is found by satisfying the conditions of ■, then
Depending on the type of operation result storage operand, process 3.
Processing is performed in which the constant value C in 2.2 is replaced with the constant value R.

■ ■の条件を満たさない場合、処理3.2の■の処理
を行う。
(2) If the condition (2) is not satisfied, the process (2) in Process 3.2 is performed.

不要命令削除手段4は、解析対象の命令ブロックに対し
て処理4、■を行い、さらに処理4.2〜4.4を繰り
返し、解析対象の命令ブロック内で設定したオペランド
が参照されないうちに再び設定される場合を見つけて、
前の設定命令を不要命令と見なして削除する。
The unnecessary instruction deletion means 4 performs processing 4 and (2) on the instruction block to be analyzed, and further repeats processing 4.2 to 4.4, and deletes the operand again before the operand set in the instruction block to be analyzed is referenced. Find the case where it is set,
The previous setting command is considered unnecessary and deleted.

mユ上ニレジスクチ−プル8の全エントリの設定フラグ
をオフにし、メモリテーブル9の全エントリを削除する
On the m unit, the setting flags of all entries in the register table 8 are turned off, and all entries in the memory table 9 are deleted.

11↓−1=解析対象の命令ブロック内の命令を制御移
行の逆順にたどり、解析対象の命令を決め、処理4.3
および4.4の順に処理する。
11↓-1 = Follow the instructions in the instruction block to be analyzed in the reverse order of control transition, decide the instruction to be analyzed, and process 4.3
and 4.4.

m工づ□:解析対象の命令の設定オペランドを分類して
、各々以下のように、以降で参照されないうちに設定が
あったオペランドならば、不要命令と見なして削除し、
その以外ならばそのオペランドに対して設定があった旨
の情報を残しておく。
m-engineering □: Classify the setting operands of the instruction to be analyzed, and if the operands have been set before being referenced later, as shown below, consider them unnecessary instructions and delete them.
Otherwise, information indicating that a setting has been made for that operand is left.

レジスタの場合ニレジスタテ−プル8の該当するエント
リの設定フラグがオフならばオンにする。
In the case of a register, if the setting flag of the corresponding entry in the second register table 8 is off, it is turned on.

設定フラグがオンならば、命令展開メモリ6内の解析対
象の命令をN0P(No  0Peratjon)命令
に置き換える。
If the setting flag is on, the instruction to be analyzed in the instruction expansion memory 6 is replaced with an N0P (No 0 Peratjon) instruction.

メモリの場合:メモリテーブル9に同じメモリ情報をも
つエントリがなければ、新しくエントリを追加して、メ
モリ情報を設定する。あれば、命令展開メモリ6内の解
析対象の命令をNOP命令に置き換える。
In the case of memory: If there is no entry with the same memory information in the memory table 9, a new entry is added and the memory information is set. If so, the instruction to be analyzed in the instruction expansion memory 6 is replaced with a NOP instruction.

U↓ユ土:解析対象の命令の参照オペランドを分類して
、各々以下のように、そのオペランドに対して参照があ
った旨の情報を残しておく。
U↓U soil: Classify the reference operands of the instruction to be analyzed, and leave information indicating that there is a reference to each operand as shown below.

レジスタの場合ニレジスタテ−プル8の該当するエント
リの設定フラグをオフにする。
In the case of a register, the setting flag of the corresponding entry in register table 8 is turned off.

メ干りの場合:メモリテーブル9に同じメモリ情報をも
つエントリがなければ、何もしない。あれば、そのエン
トリを削除する。また、該メモリと同じ領域の一部また
は全部をアクセスする可能性のあるメモリのエントリも
削除する。
In case of failure: If there is no entry with the same memory information in the memory table 9, nothing is done. If so, delete that entry. Also, memory entries that may access part or all of the same area as the memory are also deleted.

最後に、命令出力手段5は、定数値伝播手段3および不
要命令削除手段4で最適化された命令展開メモリ6中の
命令を、命令を格納してあった任意の命令格納媒体10
に出力する。
Finally, the instruction output means 5 transfers the instructions in the instruction expansion memory 6 that have been optimized by the constant value propagation means 3 and the unnecessary instruction deletion means 4 to any instruction storage medium 1 that has stored the instructions.
Output to.

〔発明の効果〕〔Effect of the invention〕

以上説明したように本発明は、線形に制御移行する範囲
内の命令に対してオペランドの定数値を命令コードによ
って以降の命令のオペランドに伝播していくことによっ
てコンパイル時に可能な定数計算を行い、より速い命令
に置き換えたり命令の置換えに伴って不要となる不要命
令を削除したりすることにより、オブジェクトプログラ
ムのサイズの縮小や実行スピードの短縮を図ることがで
きるという効果がある。
As explained above, the present invention performs constant calculation possible at compile time by propagating constant values of operands for instructions within the range of linear control transfer to the operands of subsequent instructions by instruction code, By replacing instructions with faster instructions or deleting unnecessary instructions that become unnecessary due to instruction replacement, it is possible to reduce the size of the object program and shorten the execution speed.

また、機械語命令に対して本方式を適用することによっ
て同一アーキテクチャ上のコンパイラに対して汎用的に
適用することが可能となり、さらにコンパイラが出力し
たオブジェクトプログラムに対しても適用可能になると
いう効果がある。
In addition, by applying this method to machine language instructions, it becomes possible to apply it universally to compilers on the same architecture, and furthermore, it becomes possible to apply it to object programs output by compilers. There is.

【図面の簡単な説明】[Brief explanation of the drawing]

第1図は本発明の一実施例に係る定数値伝播最適化方式
の構成を示すブロック図、 第2図は第1図中の命令展開メモリおよびブロックテー
ブルの内容を示す図、 第3図は第1図中のレジスタテーブルの内容を示す図、 第4図は第1図中のメモリテーブルの内容を示す図であ
る。 図において、 1・・・命令入力手段、 2・・・命令ブロック分割手段、 3・・・定数値伝播手段、 4・・・不要命令削除手段、 5・・・命令出力手段、 6・・・命令展開メモリ、 7゛・・・ブロックテーブル、 8・・・レジスタテーブル、 9・・・メモリテーブル、 10・・命令格納媒体である。
FIG. 1 is a block diagram showing the configuration of a constant value propagation optimization method according to an embodiment of the present invention; FIG. 2 is a diagram showing the contents of the instruction expansion memory and block table in FIG. 1; FIG. 3 is a diagram showing the contents of the instruction expansion memory and block table in FIG. FIG. 4 is a diagram showing the contents of the register table in FIG. 1, and FIG. 4 is a diagram showing the contents of the memory table in FIG. In the figure, 1... Instruction input means, 2... Instruction block division means, 3... Constant value propagation means, 4... Unnecessary instruction deletion means, 5... Instruction output means, 6... Instruction expansion memory, 7゛...Block table, 8...Register table, 9...Memory table, 10...Instruction storage medium.

Claims (1)

【特許請求の範囲】 一命令の大きさがすべて同じである命令セットをもった
アーキテクチャ上において、 命令格納媒体から命令の並びを入力してメモリ上に展開
する命令入力手段と、 この命令入力手段によりメモリ上に展開された命令を解
析して分岐命令の直後と分岐先ラベル位置とで命令の並
びを分割して命令ブロックを作成する命令ブロック分割
手段と、 この命令ブロック分割手段により分割された命令ブロッ
クごとに命令およびそのオペランドを解析して移送命令
のオペランド間で定数値を伝播し定数値と同値なレジス
タおよびメモリからの移送命令を定数値の移送命令に置
き換えたり演算命令の参照オペランドがすべて定数値な
らびに定数値と同値なレジスタおよびメモリの場合に定
数演算を行って演算命令を定数値の移送命令に置き換え
たりする定数値伝播手段と、 この定数値伝播手段により命令の置換えがなされた命令
ブロック内の不要命令を削除する不要命令削除手段と、 前記定数値伝播手段による定数値伝播および前記不要命
令削除手段による不要命令削除の最適化がなされた命令
列を命令格納媒体に出力する命令出力手段と を有することを特徴とする定数値伝播最適化方式。
[Claims] In an architecture having an instruction set in which each instruction has the same size, an instruction input means for inputting a sequence of instructions from an instruction storage medium and expanding it on a memory; an instruction block dividing means for creating an instruction block by analyzing the instructions expanded on the memory by dividing the sequence of instructions immediately after the branch instruction and at the branch destination label position; It analyzes instructions and their operands for each instruction block, propagates constant values between operands of transfer instructions, replaces transfer instructions from registers and memory with the same value as a constant value, and replaces reference operands of arithmetic instructions with transfer instructions with constant values. A constant value propagation means that performs a constant operation and replaces an operation instruction with a transfer instruction of a constant value in the case of all constant values and registers and memories that have the same value as the constant value; and a constant value propagation means that replaces instructions. unnecessary instruction deletion means for deleting unnecessary instructions in the instruction block; and outputting an instruction string to an instruction storage medium after optimization of constant value propagation by the constant value propagation means and unnecessary instruction deletion by the unnecessary instruction deletion means. A constant value propagation optimization method comprising: instruction output means.
JP12067390A 1990-05-10 1990-05-10 System for optimizing propagation of constant value Pending JPH0417031A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP12067390A JPH0417031A (en) 1990-05-10 1990-05-10 System for optimizing propagation of constant value

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP12067390A JPH0417031A (en) 1990-05-10 1990-05-10 System for optimizing propagation of constant value

Publications (1)

Publication Number Publication Date
JPH0417031A true JPH0417031A (en) 1992-01-21

Family

ID=14792104

Family Applications (1)

Application Number Title Priority Date Filing Date
JP12067390A Pending JPH0417031A (en) 1990-05-10 1990-05-10 System for optimizing propagation of constant value

Country Status (1)

Country Link
JP (1) JPH0417031A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP0749067A2 (en) * 1995-06-16 1996-12-18 Matsushita Electric Industrial Co., Ltd. Optimizer
US5644769A (en) * 1993-06-14 1997-07-01 Matsushita Electric Industrial Co., Ltd. System for optimizing program by virtually executing the instruction prior to actual execution of the program to invalidate unnecessary instructions

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5644769A (en) * 1993-06-14 1997-07-01 Matsushita Electric Industrial Co., Ltd. System for optimizing program by virtually executing the instruction prior to actual execution of the program to invalidate unnecessary instructions
EP0749067A2 (en) * 1995-06-16 1996-12-18 Matsushita Electric Industrial Co., Ltd. Optimizer
EP0749067A3 (en) * 1995-06-16 1997-05-14 Matsushita Electric Ind Co Ltd Optimizer
US5842021A (en) * 1995-06-16 1998-11-24 Matsushita Electric Industrial Co., Ltd. Optimizer

Similar Documents

Publication Publication Date Title
US6243864B1 (en) Compiler for optimizing memory instruction sequences by marking instructions not having multiple memory address paths
KR910010301A (en) Command designation method and execution device
EP1107111A3 (en) System and method for register renaming
JPS6325733A (en) Compiler processing system
JPH0721034A (en) Character string copying processing method
US4417305A (en) Method for evaluating boolean expressions
JPH0522936B2 (en)
Anantharaman et al. A hardware accelerator for speech recognition algorithms
JPH0417031A (en) System for optimizing propagation of constant value
Watanabe et al. Evaluation of fuzzy instructions in a RISC processor
JPH03135630A (en) Instruction scheduling system
JP3580394B2 (en) Program conversion device and program conversion method
KR930004861A (en) Information processing system
JPS5846439A (en) Program editing method of computer
Wiedmann Efficiency in the APL environment—a full arsenal for attacking CPU hogs
JPS5829051A (en) Operation processing device
JPH09106351A (en) Variable renaming method
JP3240647B2 (en) Computer language structured processing
JPH04287126A (en) Pipe-line control system
JPH04247527A (en) Command schedule for computer
Middleton Some transformations of relevance to report generation
JPS61123904A (en) Logic arithmetic device
JP2001229030A (en) Program optimization processor and program optimizing method
JPS60258648A (en) Program optimization processing system
JPS62202264A (en) Vector operation processing system