|
21 | 21 | #include "tket/Mapping/LexiRouteRoutingMethod.hpp" |
22 | 22 | #include "tket/Mapping/MappingManager.hpp" |
23 | 23 | #include "tket/Mapping/Verification.hpp" |
| 24 | +#include "tket/Ops/ClExpr.hpp" |
24 | 25 | #include "tket/Ops/ClassicalOps.hpp" |
25 | 26 | #include "tket/Placement/Placement.hpp" |
26 | 27 | #include "tket/Predicates/CompilationUnit.hpp" |
@@ -2387,4 +2388,31 @@ SCENARIO("Lexi route produces incorrect bimaps") { |
2387 | 2388 | REQUIRE(mm.route_circuit_with_maps(circ, config, maps)); |
2388 | 2389 | REQUIRE(check_permutation(circ, maps)); |
2389 | 2390 | } |
| 2391 | +SCENARIO("Lexi route with ClExprOps in the lookahead slice") { |
| 2392 | + // segfault Github #2180: advance_next_2qb_slice read the quantum in-edge of |
| 2393 | + // a purely classical vertex, which has none. |
| 2394 | + Circuit circ(3, 3); |
| 2395 | + circ.add_op<unsigned>(OpType::CX, {0, 1}); |
| 2396 | + circ.add_op<unsigned>(OpType::CX, {2, 1}); |
| 2397 | + circ.add_conditional_gate<unsigned>(OpType::H, {}, {2}, {2}, 1); |
| 2398 | + ClExpr bit_or(ClOp::BitOr, {ClBitVar{0}, ClBitVar{1}}); |
| 2399 | + circ.add_op<unsigned>( |
| 2400 | + std::make_shared<const ClExprOp>( |
| 2401 | + WiredClExpr(bit_or, {{0, 0}, {1, 1}}, {}, {2})), |
| 2402 | + {1, 2, 0}); |
| 2403 | + ClExpr bit_and(ClOp::BitAnd, {ClBitVar{0}, ClBitVar{1}}); |
| 2404 | + circ.add_op<unsigned>( |
| 2405 | + std::make_shared<const ClExprOp>( |
| 2406 | + WiredClExpr(bit_and, {{0, 0}, {1, 1}}, {}, {2})), |
| 2407 | + {1, 0, 2}); |
| 2408 | + circ.add_op<unsigned>(OpType::CX, {0, 2}); |
| 2409 | + circ.add_op<unsigned>(OpType::CX, {0, 2}); |
| 2410 | + Architecture arc({{Node(0), Node(1)}, {Node(1), Node(2)}}); |
| 2411 | + MappingManager mm(std::make_shared<Architecture>(arc)); |
| 2412 | + std::vector<RoutingMethodPtr> config = { |
| 2413 | + std::make_shared<LexiLabellingMethod>(), |
| 2414 | + std::make_shared<LexiRouteRoutingMethod>()}; |
| 2415 | + REQUIRE(mm.route_circuit(circ, config)); |
| 2416 | + REQUIRE(respects_connectivity_constraints(circ, arc, false)); |
| 2417 | +} |
2390 | 2418 | } // namespace tket |
0 commit comments