发明名称 |
Optimizing if statements in computer programming |
摘要 |
A method for optimizing if statements in a program includes obtaining, by a processing device, for each of conditional expressions of a plurality of if statements in the program, a set of conditional expressions having an inclusion relation; computing, for each of the set, a position with low execution frequency in the program as a move destination of a conditional expression having an inclusion relation, using information of the set in which the conditional expression is included; and moving the conditional expression to the computed move destination of the conditional expression. |
申请公布号 |
US9495140(B2) |
申请公布日期 |
2016.11.15 |
申请号 |
US201615045731 |
申请日期 |
2016.02.17 |
申请人 |
INTERNATIONAL BUSINESS MACHINES CORPORATION |
发明人 |
Kawahito Motohiro |
分类号 |
G06F9/45;G06F11/36 |
主分类号 |
G06F9/45 |
代理机构 |
Cantor Colburn LLP |
代理人 |
Cantor Colburn LLP ;Razavi Keivan |
主权项 |
1. A non-transitory computer readable storage media having instructions stored thereon that, when executed by a computer, implement a method for optimizing if statements in a program, the method comprising:
obtaining, for a conditional expression used in a conditional statement in the program, a set of conditional expressions having an inclusion relation; computing a first provisional cost corresponding to the conditional expression being positive, and a second provisional cost corresponding to the conditional expression being negative; and moving the conditional expression to a move destination, wherein the move destination is determined by performing a data-flow analysis using expressions of positive and negative conditions of the conditional expression, and wherein moving the conditional expression comprises: in response to a result of the conditional expression not being cached in a variable, generating an if statement for the conditional expression and caching the result of the conditional expression in a new variable, wherein the if statement is generated in increasing order of the first provisional cost and the second provisional cost; and in response to the result of the conditional expression being cached in a variable, replacing a conditional operator of the conditional expression with a logical operator, prior to caching the result in the new variable. |
地址 |
Armonk NY US |