When forwarding a LoadInst to another statement, a map that translates their domain is needed. Before this patch, is was computed by appending the def-to-use map to the def-to-target of the operand tree's target. This patch lets the new method getDefToTarget to is. This is computationally less expensive due to:
- Caching of the result such that it can be used for multiple operands tree to the same target.
- The map is only computed when there is a LoadInst that needs it.
- It is only computed for the statement requiring the translator map, instead of having an intermediate result for every edge in the operand tree.
The downside is that this scheme cannot handle forwarding from a previous loop iteration (which would require the entire path from statement to target). Since ForwardOpTree currently does not support forwarding across loop iterations, this was not needed anyway.
This was written in reaction to the compilation timeout in GrTestUtils.cpp by the aosp-O3-polly-before-vectorizer-unprofitable buildbot. This patch may not solve the timeout itself, but would enable other mitigations such as reducing the max-computations limit for ForwardOptree or drastically simplifying the computations needed for the translator map if the schedule is still the original from ScopInfo.