In case the schedule has not changed and the operand tree root uses a value defined in an ancestor loop, the def-to-target mapping is trivial. Let the SCoP be
for (int i < 0; i < N; i+=1) { DefStmt: D = ...; for (int j < 0; j < N; j+=1) { TargetStmt: use(D); } }
then the DefStmt-to-TargetStmt mapping is
{ DefStmt[i] -> TargetStmt[i,j] }
This case should apply on the majority of cases. This patch detects this case and directly construct the expected mapping. This assumes that the mapping never crosses the loop header DefStmt is in, which ForwardOpTree does not support at the moment anyway.
This should fix the timeout while compiling GrTestUtils.cpp of the Qualcom aosp buildbot. It still needs nearly 5 minutes to compile (which should be below the timeout), but no noticeable time is spent in the getDefToTarget function anymore.