Perform the GCD test if both, the source and the destination nodes, are in the form a0*i0 + a1*i1 + ... an*in + c.
| 1073 | // Perform the GCD test if both, the source and the destination nodes, are in |
| 1074 | // the form a0*i0 + a1*i1 + ... an*in + c. |
| 1075 | bool LoopDependenceAnalysis::GCDMIVTest( |
| 1076 | const std::pair<SENode*, SENode*>& subscript_pair) { |
| 1077 | auto source = std::get<0>(subscript_pair); |
| 1078 | auto destination = std::get<1>(subscript_pair); |
| 1079 | |
| 1080 | // Bail out if source/destination is in an unexpected form. |
| 1081 | if (!IsInCorrectFormForGCDTest(source) || |
| 1082 | !IsInCorrectFormForGCDTest(destination)) { |
| 1083 | return false; |
| 1084 | } |
| 1085 | |
| 1086 | auto source_recurrences = GetAllTopLevelRecurrences(source); |
| 1087 | auto dest_recurrences = GetAllTopLevelRecurrences(destination); |
| 1088 | |
| 1089 | // Bail out if all offsets and coefficients aren't constant. |
| 1090 | if (!AreOffsetsAndCoefficientsConstant(source_recurrences) || |
| 1091 | !AreOffsetsAndCoefficientsConstant(dest_recurrences)) { |
| 1092 | return false; |
| 1093 | } |
| 1094 | |
| 1095 | // Calculate the GCD of all coefficients. |
| 1096 | auto source_constants = GetAllTopLevelConstants(source); |
| 1097 | int64_t source_constant = |
| 1098 | CalculateConstantTerm(source_recurrences, source_constants); |
| 1099 | |
| 1100 | auto dest_constants = GetAllTopLevelConstants(destination); |
| 1101 | int64_t destination_constant = |
| 1102 | CalculateConstantTerm(dest_recurrences, dest_constants); |
| 1103 | |
| 1104 | int64_t delta = std::abs(source_constant - destination_constant); |
| 1105 | |
| 1106 | int64_t running_gcd = 0; |
| 1107 | |
| 1108 | running_gcd = CalculateGCDFromCoefficients(source_recurrences, running_gcd); |
| 1109 | running_gcd = CalculateGCDFromCoefficients(dest_recurrences, running_gcd); |
| 1110 | |
| 1111 | return delta % running_gcd != 0; |
| 1112 | } |
| 1113 | |
| 1114 | using PartitionedSubscripts = |
| 1115 | std::vector<std::set<std::pair<Instruction*, Instruction*>>>; |
nothing calls this directly
no test coverage detected