JPS63131231A - Elimination system for unnecessary recursive operational instruction - Google Patents

Elimination system for unnecessary recursive operational instruction

Info

Publication number
JPS63131231A
JPS63131231A JP27653286A JP27653286A JPS63131231A JP S63131231 A JPS63131231 A JP S63131231A JP 27653286 A JP27653286 A JP 27653286A JP 27653286 A JP27653286 A JP 27653286A JP S63131231 A JPS63131231 A JP S63131231A
Authority
JP
Japan
Prior art keywords
definition
intermediate language
section
statement
usage
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
JP27653286A
Other languages
Japanese (ja)
Inventor
Sumio Kikuchi
菊池 純男
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.)
Hitachi Ltd
Original Assignee
Hitachi 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 Hitachi Ltd filed Critical Hitachi Ltd
Priority to JP27653286A priority Critical patent/JPS63131231A/en
Publication of JPS63131231A publication Critical patent/JPS63131231A/en
Pending legal-status Critical Current

Links

Landscapes

  • Devices For Executing Special Programs (AREA)

Abstract

PURPOSE:To reduce operation quantity by examining that the using place of a variable exists in a same sentence number as the definition sentence when the definition of the variable of a data flow analysis part is used and confirming that the access of a user constant does not exist so as to eliminate an unnecessary definition sentence. CONSTITUTION:In case of optimizing an intermediate language developed from a source program, the existence of the use of the variable which is defined with the definition sentence in a program is examined in a check part 3, and it is examined in a check part 4 that all the using places of variable exist in the same number as the definition sentence. When the uses exist in the same sentence number as the definition sentence, a constant detection part 5 confirms that the user access does not exist in the right side of the definition sentence and an elimination part 6 eliminates the confirmed definition sentence.

Description

【発明の詳細な説明】 〔産業上の利用分野〕 本発明は計算機ソフトウェアに係り、特にコンパイラの
最適化処理に好適な、不要な再帰演算命令削除方式に関
する。
DETAILED DESCRIPTION OF THE INVENTION [Field of Industrial Application] The present invention relates to computer software, and particularly to a method for removing unnecessary recursive operation instructions suitable for compiler optimization processing.

〔従来の技術〕[Conventional technology]

従来、不要コード削除について、中田育男著。 Traditionally, about unnecessary code deletion, written by Ikuo Nakata.

[コンパイラ(産業図書、P221)JにはA=Aやル
ープ制御変数1について判定の置きかえによシI=I+
1が無用命令になれば削除できると論じているが、これ
をどういう方法で削除するのか、さらに、よシ一般的な
再帰演算を無用命令と判定する方法については論じられ
ていない。
[Compiler (Sangyo Tosho, p. 221) J requires replacement of judgment regarding A=A and loop control variable 1.
It is argued that if 1 becomes a useless instruction, it can be deleted, but there is no discussion of how to delete this, or how to determine a more general recursive operation as a useless instruction.

〔発明が解決しようとする問題点〕[Problem that the invention seeks to solve]

上記従来技術で無用命令として考えられているものはル
ープ制御変数1についてI=I+C(Cは定数)やA=
Aのように特徴のあるパターンであり、この検出方法に
ついて触れていないこと。
In the above conventional technology, the instructions considered as useless instructions are I=I+C (C is a constant) and A=
It is a characteristic pattern like A, and the detection method is not mentioned.

さらにより一般的に定義と使用が同−文内でしか出現し
ない再帰演算については配慮されておらず削除できない
という問題があった。
Furthermore, there is a problem in that, more generally, recursive operations whose definition and use occur only within the same sentence are not considered and cannot be deleted.

〔問題点を解決するための手段〕[Means for solving problems]

上記問題点は、プログラム内に出現する変数の定義・使
用の関係、すなわち、ある定義文で定義される変数がプ
ログラム内のどこで使用されているか、あるいはある使
用はどこで定義されるかという関係を解析する際、定義
点と使用点の位置情報として文番号を付加しておく手段
と、変数の定義に関してその使用が存在するか否かを調
べる手段と、使用が存在する場合でもその使用点すべて
が定義点と同一文番号であることを検出する手段と、か
つその定義文内にこれが呼び出されることによって何ら
かの変数の値を変更しうるようなユーザ関数が存在しな
いことを検出する手段とを設゛けることにより、解決さ
れる。
The above problem is related to the relationship between the definition and use of variables that appear in a program, that is, where in a program a variable defined by a certain definition statement is used, or where a certain use is defined. When analyzing, there is a means to add statement numbers as position information of definition points and usage points, a means to check whether a usage exists regarding the definition of a variable, and a method to check all usage points even if usage exists. A means for detecting that has the same statement number as the definition point, and a means for detecting that there is no user function in the definition statement that can change the value of some variable by being called. It is solved by looking at the problem.

〔作用〕[Effect]

変数の定義・使用の関係にその位置情報として文番号を
付加する手段は定義とその使用がどの文で出現している
のかという情報を提供する。変数の定義に関して、その
使用点を調べる手段とそのすべてが定義と同一文番号で
あることを検出する手段は、該定義文によって値が決定
される変数自身及び該変数とEQUIVALENCE(
エクィパレンス)宣言されている変数の使用が他の文に
存在しないことと該変数がC0MM0N(コモン)宣言
されていないことを確認しこの定義文の削除による結果
不正を抑止する。さらに、該定義文の右辺にユーザ関数
が存在しないことを検出する手段は。
The means of adding a sentence number as position information to the definition/use relationship of a variable provides information as to which sentence the definition and its use appear. Regarding the definition of a variable, the means to check its usage points and the means to detect that all of them have the same statement number as the definition are the variable itself whose value is determined by the definition statement and the EQUIVALENCE (
Equiparence) It is confirmed that the declared variable is not used in any other statement and that the variable is not declared C0MM0N (common) to prevent incorrect results due to deletion of this definition statement. Furthermore, what is the means for detecting that no user function exists on the right side of the definition statement?

該定義文が実行されてユーザ関数により更新された値が
使用されていたのに該定義文の削除後は更新されずに使
用されることになり、削除によって実行結果が変わって
しまうため、このような関数呼び出しが存在しないこと
を保証する。このような手段によって、定義文を削除す
ることによる結果不正を発生させることがない。
This is because the value updated by the user function was used when the definition statement was executed, but after the definition statement is deleted, it will be used without being updated, and the execution result will change due to deletion. Guarantees that there are no such function calls. By using such a means, it is possible to prevent an incorrect result from being caused by deleting a definition statement.

〔実施例〕〔Example〕

以下1本発明の一実施例を図面を参照しつつ説明する。 An embodiment of the present invention will be described below with reference to the drawings.

第1図は本発明の不要コード削除部の処理構成図、第2
図は本発明に用いるコンパイラの一実施例の構成図、第
3図は本発明の詳細な説明図、第4図は第1図の動作説
明図である。
Fig. 1 is a processing configuration diagram of the unnecessary code deletion section of the present invention;
The figure is a block diagram of one embodiment of the compiler used in the present invention, FIG. 3 is a detailed explanatory diagram of the present invention, and FIG. 4 is an explanatory diagram of the operation of FIG. 1.

第2図において、7は記憶装置に格納されているソース
プログラム、8はコンパイラ、14はコンパイルされて
記憶装置上に格納される目的プログラムである。コンパ
イラ8は記憶装置からソースプログラムを読み込んで所
望の目的プログラムを記憶装置上に生成する。このとき
、第2図に示された各部は次の処理を行う。すなわち、
ソース解析部9は読み込んだソースプログラムを文解釈
し中間言語に展開する。中間言語最適化部10は効率の
よい目的プログラムを生成するために中間言語に対して
6洩の最適化を施し、中間言語の変更を行う。17で行
われる最適化は制御フロー解析部15とデータフロー解
析部16において解析される制御フロー情報とデータフ
ロー情報に基づいて行われる。記憶域割付は部11では
中間言語内に出現する各種データに対して記憶域内番地
を割付ける。レジスタ割付は部12では中間言語内に現
われたデータに対してレジスタを割付ける。
In FIG. 2, 7 is a source program stored in a storage device, 8 is a compiler, and 14 is a target program that is compiled and stored in the storage device. The compiler 8 reads a source program from a storage device and generates a desired target program on the storage device. At this time, each section shown in FIG. 2 performs the following processing. That is,
The source analysis unit 9 interprets the sentences of the read source program and develops it into an intermediate language. The intermediate language optimization unit 10 performs six optimizations on the intermediate language and changes the intermediate language in order to generate an efficient target program. The optimization performed in step 17 is performed based on the control flow information and data flow information analyzed by the control flow analysis section 15 and the data flow analysis section 16. In the storage area allocation section 11, addresses within the storage area are allocated to various data appearing in the intermediate language. In register allocation section 12, registers are allocated to data appearing in the intermediate language.

目的プログラム出力部13は機械命令語を生成し。The target program output unit 13 generates machine command words.

命令語レベルで最適化を行った後、記憶装置14に目的
プログラムを出力する。
After optimization at the instruction word level, the target program is output to the storage device 14.

第1図は第2図の中間言語最適化部10において実施さ
れる各種鍛適化処理の1つである。不要コード削除処理
構成図である。本図において、1は不要コード削除処理
部、2はデータフロー情報ファイル、3はプログラム内
の定義文により定義される変数の使用が1つ以上あるか
否かを調べる使用有無チェック部、4は上記使用回数が
1以上のときその使用場所すべてが定義文と同一番号に
存在することを調べる使用場所チェック部、5は上記使
用が定義文と同一文番号のときに該定義文の右辺にユー
ザ関数呼び出しが存在しないことを確認する関数検出部
、6は5で確認された定義文を削除する定義文削除部で
ある。
FIG. 1 shows one of various training optimization processes performed in the intermediate language optimization section 10 of FIG. 2. It is a block diagram of an unnecessary code deletion process. In this figure, 1 is an unnecessary code deletion processing unit, 2 is a data flow information file, 3 is a usage check unit that checks whether one or more variables defined by definition statements in the program are used, and 4 is a usage check unit that checks whether one or more variables defined by definition statements in the program are used. When the above usage count is 1 or more, the usage location check part checks whether all the usage locations exist with the same number as the definition statement. A function detection section 6 confirms that there is no function call, and a definition statement deletion section 6 deletes the definition statement confirmed in step 5.

以上の構成に基づき、第3図の例により第1図の動作を
第4図で説明する。第3図の式(1)の定義文において
fはユーザ定義関数とし、fはこれが呼ばれるとC0M
M0N宣言されている変数りの値及び引数の値を変更す
る性質をもつものとする。
Based on the above configuration, the operation shown in FIG. 1 will be explained with reference to FIG. 4 using the example shown in FIG. In the definition statement of equation (1) in Figure 3, f is a user-defined function, and when f is called, C0M
It has the property of changing the values of variables and arguments declared as M0N.

定義文によって定義される変数に関し、使用有無チェッ
ク部3はデータフロー情報を参照して該変数の使用点の
数を調べる。データフロー情報ファイル2には、中間言
語内に出現する全変数に対してその定義・使用関数、つ
まシある定義に対してこの値をどの文で使用しているか
を示す関係が解析され格納されている。この情報から使
用が全く存在しない場合には関数検出部5の処理を行う
Regarding the variable defined by the definition statement, the usage check unit 3 checks the number of usage points of the variable by referring to the data flow information. The data flow information file 2 analyzes and stores the definitions and usage functions for all variables that appear in the intermediate language, as well as the relationships that indicate in which statement this value is used for a certain definition. ing. Based on this information, if there is no use at all, the function detection unit 5 performs processing.

一方、使用が1回以上存在する場合には、使用場所チェ
ック部14はその全使用点が定義文と同一文番号である
かを確認する。
On the other hand, if the usage exists one or more times, the usage location check unit 14 checks whether all the usage points have the same statement number as the definition statement.

たとえば、第3図における定義文(1)と(3)は、定
義に対する使用が1回のみでかつ使用場所が定義文と同
一文番号である。もし、1つでも異なる文番号をもつ使
用点が存在するときは6次の定義文の処理を行う。この
使用点には該定義変数とEQUIVALENCE宣言さ
れている変数の使用も含む。
For example, definition sentences (1) and (3) in FIG. 3 are used only once for the definition and are used at the same sentence number as the definition sentence. If there is at least one usage point with a different statement number, the sixth-order definition statement is processed. This point of use includes the use of the defined variable and variables declared EQUIVALENCE.

もし、全使用点が定義文と同一文番号の場合には、関数
検出部5の処理を行う。ここでは該定義文の右辺にユー
ザ関数が存在しないことを確認する。こうする理由は、
C0MM0N亘言されている変数や関数の引数として使
用される変数はこの関数呼び出しによシその変数が更新
される可能性があシ、さらにこの値を他で参照しうるた
め、もしこの関数が実行されないと結果不正を発生しう
るからである。たとえば、第3図の式(1)は変数Aの
定義と使用は同一文番号となるが、関数fの実行によシ
コモン宣言されている変数りおよび引数Bの値が更新さ
れる。よって1式(1)が削除された場合と削除されな
い場合とでCの値が異なってしまう。一方6式(3)は
このようなことがないためこの文を削除しても結果不正
を発生させることがない。
If all usage points have the same statement number as the definition statement, processing by the function detection unit 5 is performed. Here, it is confirmed that no user function exists on the right side of the definition statement. The reason for doing this is
C0MM0N variables or variables used as function arguments may be updated by this function call, and this value may be referenced elsewhere, so if this function This is because if it is not executed, incorrect results may occur. For example, in equation (1) of FIG. 3, the definition and use of variable A are in the same statement number, but the execution of function f updates the commonly declared variables and the value of argument B. Therefore, the value of C will be different depending on whether Equation 1 (1) is deleted or not. On the other hand, Equation 6 (3) does not have this problem, so even if this statement is deleted, no incorrect results will occur.

もし、定義文の右辺に関数が存在する場合には。If a function exists on the right side of the definition statement.

次の定義文の処理を行う。関数検出部5の確認が終了し
たら、定義文削除部6は該定義文を削除する。
Processes the next definition statement. When the function detection section 5 has finished checking, the definition statement deletion section 6 deletes the definition statement.

本実施例によれば、主としてループ内に出現しうる再帰
的演算を削除できるため、オブジェクト効率を向上させ
る効果がるる。
According to this embodiment, it is possible to eliminate recursive operations that may appear in loops, thereby improving object efficiency.

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

本発明によれば、プログラム内の演算量を削減できる効
果のみでなく、定義文削除により変数が減少するためレ
ジスタ割付は対象も減少し、レジスタに割付けたままで
演算できるケースが増えることによりストア+5TOR
E)、ロード(LOAD)命令の削減効果もあり、オブ
ジェクト実行性能を向上させる効果がある。
According to the present invention, in addition to the effect of reducing the amount of calculations in a program, the number of variables reduced by deleting definition statements reduces the scope of register allocation, and the number of cases in which operations can be performed while remaining allocated to registers increases, resulting in a storage + 5 TOR
E) There is also the effect of reducing the number of load (LOAD) instructions, which has the effect of improving object execution performance.

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

第1図は本発明の一実施例の処理構成図、第2図は本発
明に用いるコンパイラの一実施例の構成図、第3図は本
発明の詳細な説明図、第4図は第1図の動作説明図であ
る。 1・・・不要コード削除部、2・・・データフロー情報
ファイル、3・・・使用有無チェック部、4・・・使用
場所チェック部、5・・・関数検出部、6・・・定義文
削除部。 7・・・ソースプログラムを格納する記憶装置。 代理人 弁理士 小川勝馬 、パ]“ 5  ′。 SI+¥1 2 テ乙り70−楕旬辷lイル 5 聞収−許ヒム叡p
3 4ナー弔 OCト呼I、りOb え人文、等]γオ
とモψあ 2  口 名 3 団 嘱牛図
FIG. 1 is a processing block diagram of an embodiment of the present invention, FIG. 2 is a block diagram of an embodiment of a compiler used in the present invention, FIG. 3 is a detailed explanatory diagram of the present invention, and FIG. It is an explanatory diagram of the operation of the figure. DESCRIPTION OF SYMBOLS 1... Unnecessary code deletion section, 2... Data flow information file, 3... Usage check section, 4... Usage location check section, 5... Function detection section, 6... Definition statement Deletion part. 7...Storage device for storing source programs. Agent: Patent attorney Katsuma Ogawa, PA] " 5 '. SI + ¥ 1 2 Teoori 70 - Ellipse 70 - Ellipse 5 Listening - Huh Hime P
3 4ner condolence OC to call I, ri Ob e humanities, etc.] γ o and mo ψ a 2 Oral name 3 Group ox illustration

Claims (1)

【特許請求の範囲】[Claims] 1、与えられたソースプログラムの文解釈を行い中間言
語に展開するソース解析部、中間言語を入力として制御
フロー、データフロー解析を行いこの情報をもとに中間
言語に対して各種の最適化を施し中間言語を変更する中
間言語最適化部、中間言語内に出現する各種データに対
して記憶域内番地を割当てる記憶域割付け部、中間言語
に現われたデータに実際の資源を割当てるレジスタ割付
け部、および目的プログラム出力部を備えたコンパイラ
において、プログラム中に出現する変数についてその定
義・使用の関係を解析したデータフロー情報にそれらが
出現している位置情報として文番号を付加するデータフ
ロー解析部変数の定義に関してその使用が1回以上ある
か否かを調べる使用有無チェック部、使用が1回以上の
ときにそのすべての使用場所が定義文と同一文番号に存
在することを調べる使用場所チェック部、定義文の右辺
にユーザ関数呼び出しが存在しないことを確認する関数
検出部、不要な定義文を削除する定義文削除部を設けた
ことを特徴とする不要な再帰演算命令削除方式。
1. A source analysis unit that interprets the sentences of a given source program and develops it into an intermediate language. It takes the intermediate language as input, performs control flow and data flow analysis, and performs various optimizations for the intermediate language based on this information. An intermediate language optimization section that changes the intermediate language, a storage allocation section that allocates addresses in storage to various data appearing in the intermediate language, a register allocation section that allocates actual resources to the data appearing in the intermediate language, and In a compiler equipped with a program output section, the data flow analysis section adds statement numbers as location information where variables appear in the data flow information that analyzes the definition and usage relationships of variables that appear in the program. a usage presence check unit that checks whether a definition has been used more than once; a usage location check unit that checks if all usage locations are in the same sentence number as the definition statement when the definition has been used more than once; A method for deleting unnecessary recursive operation instructions, characterized in that a function detection section confirms that there is no user function call on the right side of a definition statement, and a definition statement deletion section deletes unnecessary definition statements.
JP27653286A 1986-11-21 1986-11-21 Elimination system for unnecessary recursive operational instruction Pending JPS63131231A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP27653286A JPS63131231A (en) 1986-11-21 1986-11-21 Elimination system for unnecessary recursive operational instruction

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP27653286A JPS63131231A (en) 1986-11-21 1986-11-21 Elimination system for unnecessary recursive operational instruction

Publications (1)

Publication Number Publication Date
JPS63131231A true JPS63131231A (en) 1988-06-03

Family

ID=17570782

Family Applications (1)

Application Number Title Priority Date Filing Date
JP27653286A Pending JPS63131231A (en) 1986-11-21 1986-11-21 Elimination system for unnecessary recursive operational instruction

Country Status (1)

Country Link
JP (1) JPS63131231A (en)

Similar Documents

Publication Publication Date Title
KR101247062B1 (en) Method of instrumenting code having restrictive calling conventions
US5613118A (en) Profile-based preprocessor for optimizing programs
US7406685B2 (en) System and method for whole-system program analysis
Sinha et al. System-dependence-graph-based slicing of programs with arbitrary interprocedural control flow
US5428793A (en) Method and apparatus for compiling computer programs with interproceduural register allocation
US5778233A (en) Method and apparatus for enabling global compiler optimizations in the presence of exception handlers within a computer program
US7356813B2 (en) System and method for optimizing a program
US7950005B2 (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
JPH07129412A (en) Method and equipment for compilation
US5937191A (en) Determining and reporting data accessing activity of a program
US7143402B2 (en) Method and apparatus for precision optimization in compiled programs
JP3813087B2 (en) Program conversion method, computer apparatus and program
JP2004164554A (en) Device and method for executing and monitoring program
JP2002259134A (en) Method and device for optimizing post link code
JPS6325733A (en) Compiler processing system
JP3179536B2 (en) How to operate a digital computer
US6665864B1 (en) Method and apparatus for generating code for array range check and method and apparatus for versioning
JP3062266B2 (en) Support device
JPH07230386A (en) Data processor and method for calling control routine
US5946493A (en) Method and system in a data processing system for association of source code instructions with an optimized listing of object code instructions
US20060174248A1 (en) Software tool for automatically protecting shared resources within software source code
EP1121641A1 (en) Apparatus and method for program optimizing
JPH0766342B2 (en) Program test equipment
JPS63131231A (en) Elimination system for unnecessary recursive operational instruction
JP4055197B2 (en) Device for analyzing procedures included in the program