Truncs are treated as sources if their produce a value of the same type as the one we currently trying to promote. Truncs used to be considered as a sink if their operand was the same value type.
We now allow smaller types in the search, so we should search through truncs that produce a smaller value. These truncs can then be converted to an AND mask.
This leaves sinks as being:
- points where the value in the register is being observed, such as an icmp, switch or store.
- points where value types have to match, such as calls and returns.
- zext are included to ease the transformation and are generally removed later on.
During this change, it also became apart from truncating for sinks was broken: if a sink used a source, its type information had already been lost by the time the truncation happens. So I've changed the method of caching the type information. Most of the changes are cosmetic because IRPromoter now holds all the sets as members, so they don't need to be passed around everywhere. Changes that affect code generation:
- isSink reports false for truncs and true for switches that have a conditon < TypeSize.
- ReplaceAllUsers has become a method of IRPromoter.
- TruncTysMap stores a vector of types, one for each operand.
- visited truncs are converted to AND masks.