Difference: CS255CompRules (1 vs. 2)

Revision 22008-04-08 - ChenDing

Line: 1 to 1
Deleted:
<
<
 

Competition Rules

In gimple tree, there are some opportunities to decrease the executed statements by combining several into one. The following rules are for preventing these feasible but illegal optimizations.

Line: 13 to 12
 
  • Index of an array can only be a variable or a constant.
  • Return parameter can only be a variable or a constant.
Changed:
<
<
NOTICE: Actually, you do NOT need to do any work to make the gimple tree to follow the above rules because gcc has already simplified it.
>
>
NOTE: you do NOT need to do any work to make the gimple tree to follow the above rules because gcc has already simplified it.
  After the program transformation, new temporary variables could be introduced. An example program segment
Line: 46 to 45
 L1:
Changed:
<
<
You should take scanf and printf as special instructions that need not conform to above specifications. You should not make any temporary variable to take value of the pointer passed to scanf. Remember that our language does not have pointers, so we do not deal with them. For printf, you still need to make all the arguments in variable or constant form except for the format string.
>
>
For scanf, you do not need to make any temporary variable to take value of the pointer passed to the call. Remember that our language otherwise does not have pointers, so you do not deal with pointer induced aliasing. For printf, you still need to make all the arguments in variable or constant form except for the format string.
  -- XiaomingGu - 08 Apr 2008

Revision 12008-04-08 - XiaomingGu

Line: 1 to 1
Added:
>
>

Competition Rules

In gimple tree, there are some opportunities to decrease the executed statements by combining several into one. The following rules are for preventing these feasible but illegal optimizations.

  • Left hand side of an assignment statement should be a variable or an array access.
  • Right hand side of an assignment statement should be either a variable, a constant, an array access, a function call or an expression with no more than two operands (or one operator).
  • If there is an array access in an assignment statement, the statement has only two operands - one is the array access and the other is a variable.
  • Any operand of an expression can only be a variable or a constant.
  • The predicate of a conditional jump can be one comparison operation whose two operands are either a variable or a constant.
  • Parameters to a function call can only be a variable or a constant.
  • Index of an array can only be a variable or a constant.
  • Return parameter can only be a variable or a constant.

NOTICE: Actually, you do NOT need to do any work to make the gimple tree to follow the above rules because gcc has already simplified it.

After the program transformation, new temporary variables could be introduced. An example program segment

    a = b + c[e] + d;
    if (a+d<b) goto L1;
         foo (m[a+d]);
         m[e+f] = m[a] + m[d];
    L1:

needs to be converted to something like the following:

  t1 = c[e];
  t2 = t1 + b;
  a = t2 + d;
  t3 = a + d;
  if (t3 < b) goto L1;

  t4 = a + d;
  t5 = m[t4];
  foo (t5);
  t6 = e + f;
  t7 = m[a];
  t8 = m[d];
  t9 = t7 + t8;
  m[t6] = t9;

L1:

You should take scanf and printf as special instructions that need not conform to above specifications. You should not make any temporary variable to take value of the pointer passed to scanf. Remember that our language does not have pointers, so we do not deal with them. For printf, you still need to make all the arguments in variable or constant form except for the format string.

-- XiaomingGu - 08 Apr 2008

 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding URCS? Send feedback