]> gitweb.factorcode.org Git - factor.git/blob - basis/compiler/cfg/alias-analysis/alias-analysis-docs.factor
minor cleanup to some docs.
[factor.git] / basis / compiler / cfg / alias-analysis / alias-analysis-docs.factor
1 USING: compiler.cfg.instructions help.markup help.syntax kernel ;
2 IN: compiler.cfg.alias-analysis
3
4 HELP: useless-compare?
5 { $values
6   { "insn" "a " { $link ##compare } " instruction" }
7   { "?" boolean }
8 }
9 { $description "Checks if the comparison instruction is required." } ;
10
11 ARTICLE: "compiler.cfg.alias-analysis"
12 "Alias analysis for stack operations, array elements and tuple slots"
13 "We try to eliminate redundant slot operations using some simple heuristics."
14 $nl
15 "All heap-allocated objects which are loaded from the stack, or other object slots are pessimistically assumed to belong to the same alias class."
16 $nl
17 "Freshly-allocated objects get their own alias class."
18 $nl
19 "Simple pseudo-C example showing load elimination:"
20 { $code
21   "int *x, *y, z: inputs"
22   "int a, b, c, d, e: locals"
23 }
24 "Before alias analysis:"
25 { $code
26   "a = x[2]"
27   "b = x[2]"
28   "c = x[3]"
29   "y[2] = z"
30   "d = x[2]"
31   "e = y[2]"
32   "f = x[3]"
33 }
34 "After alias analysis:"
35 { $code
36   "a = x[2]"
37   "b = a /* ELIMINATED */"
38   "c = x[3]"
39   "y[2] = z"
40   "d = x[2] /* if x=y, d=z, if x!=y, d=b; NOT ELIMINATED */"
41   "e = z /* ELIMINATED */"
42   "f = c /* ELIMINATED */"
43 }
44 "Simple pseudo-C example showing store elimination:"
45 $nl
46 "Before alias analysis:"
47 { $code
48   "x[0] = a"
49   "b = x[n]"
50   "x[0] = c"
51   "x[1] = d"
52   "e = x[0]"
53   "x[1] = c"
54 }
55 "After alias analysis:"
56 { $code
57   "x[0] = a /* dead if n = 0, live otherwise; NOT ELIMINATED */"
58   "b = x[n]"
59   "x[0] = c"
60   "/* x[1] = d */  /* ELIMINATED */"
61   "e = c"
62   "x[1] = c"
63 } ;
64
65 ABOUT: "compiler.cfg.alias-analysis"