Commit 1563edc
authored
[Utils] Fix incorrect LCSSA PHI nodes when splitting critical edges with MergeIdenticalEdges
When splitting a critical edge from a block with multiple identical
edges to an exit block while both `PreserveLCSSA` and
`MergeIdenticalEdges` are enabled, the generated LCSSA PHI
nodes in the split block would miss incoming values from merged edges.
This occurs because:
1. `MergeIdenticalEdges` merges multiple identical edges into a single
edge to the new split block.
2. `PreserveLCSSA` (in `createPHIsForSplitLoopExit`) previously assumed
only one incoming edge from the original block, creating PHI nodes
with incomplete predecessors.
The fix modifies `createPHIsForSplitLoopExit` to account for merged
edges by passing all original predecessor entries (matching the number
of merged edges) when creating PHI nodes.
This ensures all incoming values are properly reflected in the split
block's PHI nodes.
Add unittest case in `BasicBlockUtilsTest.cpp` to verify the correction
of PHI node generation in this scenario.1 parent 2f808dd commit 1563edc
File tree
2 files changed
+67
-1
lines changed- llvm
- lib/Transforms/Utils
- unittests/Transforms/Utils
2 files changed
+67
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
| 208 | + | |
| 209 | + | |
208 | 210 | | |
209 | 211 | | |
210 | 212 | | |
| |||
217 | 219 | | |
218 | 220 | | |
219 | 221 | | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
220 | 225 | | |
221 | 226 | | |
222 | 227 | | |
| |||
288 | 293 | | |
289 | 294 | | |
290 | 295 | | |
291 | | - | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
292 | 301 | | |
293 | 302 | | |
294 | 303 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
438 | 438 | | |
439 | 439 | | |
440 | 440 | | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
441 | 498 | | |
442 | 499 | | |
443 | 500 | | |
| |||
0 commit comments