| 1182 | } |
| 1183 | |
| 1184 | Constraint* LoopDependenceAnalysis::IntersectConstraints( |
| 1185 | Constraint* constraint_0, Constraint* constraint_1, |
| 1186 | const SENode* lower_bound, const SENode* upper_bound) { |
| 1187 | if (constraint_0->AsDependenceNone()) { |
| 1188 | return constraint_1; |
| 1189 | } else if (constraint_1->AsDependenceNone()) { |
| 1190 | return constraint_0; |
| 1191 | } |
| 1192 | |
| 1193 | // Both constraints are distances. Either the same distance or independent. |
| 1194 | if (constraint_0->AsDependenceDistance() && |
| 1195 | constraint_1->AsDependenceDistance()) { |
| 1196 | auto dist_0 = constraint_0->AsDependenceDistance(); |
| 1197 | auto dist_1 = constraint_1->AsDependenceDistance(); |
| 1198 | |
| 1199 | if (*dist_0->GetDistance() == *dist_1->GetDistance()) { |
| 1200 | return constraint_0; |
| 1201 | } else { |
| 1202 | return make_constraint<DependenceEmpty>(); |
| 1203 | } |
| 1204 | } |
| 1205 | |
| 1206 | // Both constraints are points. Either the same point or independent. |
| 1207 | if (constraint_0->AsDependencePoint() && constraint_1->AsDependencePoint()) { |
| 1208 | auto point_0 = constraint_0->AsDependencePoint(); |
| 1209 | auto point_1 = constraint_1->AsDependencePoint(); |
| 1210 | |
| 1211 | if (*point_0->GetSource() == *point_1->GetSource() && |
| 1212 | *point_0->GetDestination() == *point_1->GetDestination()) { |
| 1213 | return constraint_0; |
| 1214 | } else { |
| 1215 | return make_constraint<DependenceEmpty>(); |
| 1216 | } |
| 1217 | } |
| 1218 | |
| 1219 | // Both constraints are lines/distances. |
| 1220 | if ((constraint_0->AsDependenceDistance() || |
| 1221 | constraint_0->AsDependenceLine()) && |
| 1222 | (constraint_1->AsDependenceDistance() || |
| 1223 | constraint_1->AsDependenceLine())) { |
| 1224 | auto is_distance_0 = constraint_0->AsDependenceDistance() != nullptr; |
| 1225 | auto is_distance_1 = constraint_1->AsDependenceDistance() != nullptr; |
| 1226 | |
| 1227 | auto a0 = is_distance_0 ? scalar_evolution_.CreateConstant(1) |
| 1228 | : constraint_0->AsDependenceLine()->GetA(); |
| 1229 | auto b0 = is_distance_0 ? scalar_evolution_.CreateConstant(-1) |
| 1230 | : constraint_0->AsDependenceLine()->GetB(); |
| 1231 | auto c0 = |
| 1232 | is_distance_0 |
| 1233 | ? scalar_evolution_.SimplifyExpression( |
| 1234 | scalar_evolution_.CreateNegation( |
| 1235 | constraint_0->AsDependenceDistance()->GetDistance())) |
| 1236 | : constraint_0->AsDependenceLine()->GetC(); |
| 1237 | |
| 1238 | auto a1 = is_distance_1 ? scalar_evolution_.CreateConstant(1) |
| 1239 | : constraint_1->AsDependenceLine()->GetA(); |
| 1240 | auto b1 = is_distance_1 ? scalar_evolution_.CreateConstant(-1) |
| 1241 | : constraint_1->AsDependenceLine()->GetB(); |
no test coverage detected