pub enum Anchor {
Value(Value),
Address(Symbol),
}Expand description
What an expression is measured from.
Usually a value the function computed somewhere outside the loop, which whoever reads the invariant can name. Sometimes the address of a global, which nothing has to compute because it is settled at link time and is the same number everywhere in the program.
The second one is here because of where a global_addr sits. crate::licm gives it a cost of
zero and so never moves it out of a loop, which is the right call: working the address out again
is one instruction and holding it in a register across a loop is a register. But that leaves the
instruction inside the loop, and Loops::is_invariant answers by where a value is defined, so
a[i] on a file scope a came out unknown. Describing the address rather than naming a value
is the same move Widening makes, and it means a reader that wants the address in front of
the loop writes another global_addr there for the one instruction it costs. On the SQLite
amalgamation that is 178 checks at 47 sites of loop splitting’s largest census row.
See tamnd/rucc#810.
Variants§
Value(Value)
A value, which is defined outside the loop and so can be named where it is wanted.
Address(Symbol)
The address of a global, which is written again wherever it is wanted.