optimization.txt 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. Simplifications
  2. ----------------
  3. Simplification levels:
  4. 0 Do not simplify.
  5. 1 add real only to real and int only to int.
  6. 2 Same as 1, but integers are added to reals. (real1=int+real2)
  7. 3 Convert all integers to real, and then do 1.
  8. SimplifyConstants:
  9. If Mode=0: only check integrity
  10. - Evaluates all real constants, including things like Sin(5.0)
  11. - Evaluates Real
  12. CO
  13. / \
  14. / \
  15. A B
  16. / \ / \
  17. / \ / \
  18. C D E F
  19. Node types:
  20. Ci constant (nodetype=iconstnode)
  21. Cr real constant, (nodetype=constnode)
  22. Cy expression (ExprIsConstant IN Flags, things like Sin(5) or even 4 DIV 6 if integer to real is off)
  23. Cn is any of the three above constant types
  24. CO= Commutative Operator (mul, add)
  25. X Any other expression,
  26. Constants always have to be arranged Ci<Cr<Cy<
  27. if A <> CO then (C and D have no relevance)
  28. if B <> CO then (E and F have no relevance)
  29. A C D B E F
  30. action Cn - - CO Cn Cn (killed in SimplifyConstants}
  31. Cn - - CO X Cn (Changed to E=C, F=X in killed in SimplifyConstants)
  32. Cn - - CO Cn X (if A=Cx and E=Ci then swap(A,E))
  33. X - - CO
  34. ----------------
  35. (from an older version of this doc:)
  36. A D Action
  37. Xcomm <>Xcomm Process [b c d]
  38. Xcomm Xcomm Process [b c e f]
  39. <>Xcomm Xcomm Process [a e f]
  40. <>Xcomm <>Xcoom Process [a d]
  41. How to process:
  42. If Simplicationlevel<>0 then
  43. begin
  44. if (Simplicationlevel=3) or ((simplicationlevel=2) and (Cr in [])) then
  45. {convert all Ci to Cr}
  46. If more than one Ci in [] then
  47. {addall Ci's to one Ci}
  48. If more than one Cr in [] then
  49. {addall Crs to one Cr}
  50. end;
  51. {determine how many elements in set left. (in practice kept track of in code
  52. above)}
  53. If we have only one xcomm on the right, xchg right and left}
  54. {Rearrange set so that
  55. Ci < Cr < Cx < X
  56. #nodes nodes filled:
  57. 0 Not possible.
  58. 1 Root node only, but not possible (cases that could lead to this
  59. are covered by the standard simplifications)
  60. 2 A, D
  61. 3 A, e f
  62. 4 b c e f
  63. TreeType: 0 A d
  64. 1 b c d
  65. 2 A e f
  66. 3 b c e f
  67. }