Commit a203d55
🐛 Fix CtrlOp::getBodyUnitary() for operations with parameters (#1464)
## Description
While debugging test cases in #1426, I finally figured out why
`CtrlOp::getBodyUnitary()` sometimes returned an invalid
`UnitaryOpInterface`.
Whenever an operation has at least one parameter, the first operation in
the modifier's body will be a `arith.constant` and *not* the unitary
operation like it is currently assumed in the function.
This PR resolves this by iterating over all operations in the body and
only returning when the first `UnitaryOpInterface` operation has been
found or there is none.
It affects all `crx`, `crzz`, `cu`, ... operations.
Required for #1426
## Checklist:
<!---
This checklist serves as a reminder of a couple of things that ensure
your pull request will be merged swiftly.
-->
- [x] The pull request only contains commits that are focused and
relevant to this change.
- [x] I have added appropriate tests that cover the new/changed
functionality.
- [ ] I have updated the documentation to reflect these changes.
- [ ] I have added entries to the changelog for any noteworthy
additions, changes, fixes, or removals.
- [ ] I have added migration instructions to the upgrade guide (if
needed).
- [x] The changes follow the project's style guidelines and introduce no
new warnings.
- [ ] The changes are fully tested and pass the CI checks.
- [x] I have reviewed my own code changes.
---------
Co-authored-by: Daniel Haag <121057143+denialhaag@users.noreply.github.com>1 parent 6928519 commit a203d55
File tree
4 files changed
+69
-19
lines changed- mlir
- lib/Dialect
- QCO/Builder
- QC/Builder
- unittests/Dialect/QCO/IR/Modifiers
4 files changed
+69
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
317 | 317 | | |
318 | 318 | | |
319 | 319 | | |
| 320 | + | |
320 | 321 | | |
321 | 322 | | |
322 | 323 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| 34 | + | |
| 35 | + | |
33 | 36 | | |
34 | 37 | | |
35 | 38 | | |
| |||
167 | 170 | | |
168 | 171 | | |
169 | 172 | | |
170 | | - | |
| 173 | + | |
| 174 | + | |
171 | 175 | | |
172 | 176 | | |
173 | 177 | | |
| |||
228 | 232 | | |
229 | 233 | | |
230 | 234 | | |
| 235 | + | |
231 | 236 | | |
232 | | - | |
| 237 | + | |
233 | 238 | | |
234 | 239 | | |
235 | 240 | | |
| |||
262 | 267 | | |
263 | 268 | | |
264 | 269 | | |
| 270 | + | |
| 271 | + | |
265 | 272 | | |
266 | | - | |
| 273 | + | |
267 | 274 | | |
268 | 275 | | |
269 | 276 | | |
| |||
298 | 305 | | |
299 | 306 | | |
300 | 307 | | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
301 | 311 | | |
302 | | - | |
| 312 | + | |
303 | 313 | | |
304 | 314 | | |
305 | 315 | | |
| |||
355 | 365 | | |
356 | 366 | | |
357 | 367 | | |
| 368 | + | |
358 | 369 | | |
359 | | - | |
| 370 | + | |
360 | 371 | | |
361 | 372 | | |
362 | 373 | | |
| |||
390 | 401 | | |
391 | 402 | | |
392 | 403 | | |
| 404 | + | |
| 405 | + | |
393 | 406 | | |
394 | | - | |
| 407 | + | |
395 | 408 | | |
396 | 409 | | |
397 | 410 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| 36 | + | |
| 37 | + | |
35 | 38 | | |
36 | 39 | | |
37 | 40 | | |
| |||
210 | 213 | | |
211 | 214 | | |
212 | 215 | | |
| 216 | + | |
213 | 217 | | |
214 | 218 | | |
215 | 219 | | |
216 | | - | |
| 220 | + | |
217 | 221 | | |
218 | 222 | | |
219 | 223 | | |
| |||
222 | 226 | | |
223 | 227 | | |
224 | 228 | | |
| 229 | + | |
225 | 230 | | |
226 | 231 | | |
227 | 232 | | |
228 | | - | |
| 233 | + | |
229 | 234 | | |
230 | 235 | | |
231 | 236 | | |
| |||
295 | 300 | | |
296 | 301 | | |
297 | 302 | | |
| 303 | + | |
298 | 304 | | |
299 | 305 | | |
300 | | - | |
| 306 | + | |
301 | 307 | | |
302 | 308 | | |
303 | 309 | | |
304 | 310 | | |
305 | 311 | | |
306 | 312 | | |
307 | 313 | | |
| 314 | + | |
308 | 315 | | |
309 | 316 | | |
310 | 317 | | |
311 | | - | |
| 318 | + | |
312 | 319 | | |
313 | 320 | | |
314 | 321 | | |
| |||
337 | 344 | | |
338 | 345 | | |
339 | 346 | | |
| 347 | + | |
| 348 | + | |
340 | 349 | | |
341 | 350 | | |
342 | | - | |
| 351 | + | |
343 | 352 | | |
344 | 353 | | |
345 | 354 | | |
| |||
348 | 357 | | |
349 | 358 | | |
350 | 359 | | |
| 360 | + | |
| 361 | + | |
351 | 362 | | |
352 | 363 | | |
353 | 364 | | |
354 | | - | |
| 365 | + | |
355 | 366 | | |
356 | 367 | | |
357 | 368 | | |
| |||
381 | 392 | | |
382 | 393 | | |
383 | 394 | | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
384 | 398 | | |
385 | 399 | | |
386 | | - | |
| 400 | + | |
387 | 401 | | |
388 | 402 | | |
389 | 403 | | |
| |||
393 | 407 | | |
394 | 408 | | |
395 | 409 | | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
396 | 413 | | |
397 | 414 | | |
398 | 415 | | |
399 | | - | |
| 416 | + | |
400 | 417 | | |
401 | 418 | | |
402 | 419 | | |
| |||
466 | 483 | | |
467 | 484 | | |
468 | 485 | | |
| 486 | + | |
469 | 487 | | |
470 | 488 | | |
471 | 489 | | |
472 | | - | |
| 490 | + | |
473 | 491 | | |
474 | 492 | | |
475 | 493 | | |
| |||
479 | 497 | | |
480 | 498 | | |
481 | 499 | | |
| 500 | + | |
482 | 501 | | |
483 | 502 | | |
484 | 503 | | |
485 | | - | |
| 504 | + | |
486 | 505 | | |
487 | 506 | | |
488 | 507 | | |
| |||
515 | 534 | | |
516 | 535 | | |
517 | 536 | | |
| 537 | + | |
| 538 | + | |
518 | 539 | | |
519 | 540 | | |
520 | 541 | | |
521 | 542 | | |
522 | | - | |
| 543 | + | |
523 | 544 | | |
524 | 545 | | |
525 | 546 | | |
| |||
530 | 551 | | |
531 | 552 | | |
532 | 553 | | |
| 554 | + | |
| 555 | + | |
533 | 556 | | |
534 | 557 | | |
535 | 558 | | |
536 | 559 | | |
537 | | - | |
| 560 | + | |
538 | 561 | | |
539 | 562 | | |
540 | 563 | | |
| |||
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
0 commit comments