|
7 | 7 | //===----------------------------------------------------------------------===// |
8 | 8 | // |
9 | 9 | // This file "describes" induction, recurrence, and conditional scalar |
10 | | -// assignment (CSA) variables. |
| 10 | +// assignment variables. |
11 | 11 | // |
12 | 12 | //===----------------------------------------------------------------------===// |
13 | 13 |
|
@@ -424,54 +424,64 @@ class InductionDescriptor { |
424 | 424 | SmallVector<Instruction *, 2> RedundantCasts; |
425 | 425 | }; |
426 | 426 |
|
427 | | -/// A Conditional Scalar Assignment (CSA) is an assignment from an initial |
| 427 | +/// A Conditional Scalar Assignment is an assignment from an initial |
428 | 428 | /// scalar that may or may not occur. |
429 | | -class CSADescriptor { |
| 429 | +class ConditionalScalarAssignmentDescriptor { |
430 | 430 | /// If the conditional assignment occurs inside a loop, then Phi chooses |
431 | 431 | /// the value of the assignment from the entry block or the loop body block. |
432 | 432 | PHINode *Phi = nullptr; |
433 | 433 |
|
434 | | - /// The initial value of the CSA. If the condition guarding the assignment is |
435 | | - /// not met, then the assignment retains this value. |
| 434 | + /// The initial value of the ConditionalScalarAssignment. If the condition |
| 435 | + /// guarding the assignment is not met, then the assignment retains this |
| 436 | + /// value. |
436 | 437 | Value *InitScalar = nullptr; |
437 | 438 |
|
438 | 439 | /// The Instruction that conditionally assigned to inside the loop. |
439 | 440 | Instruction *Assignment = nullptr; |
440 | 441 |
|
441 | | - /// Create a CSA Descriptor that models a valid CSA with its members |
442 | | - /// initialized correctly. |
443 | | - CSADescriptor(PHINode *Phi, Instruction *Assignment, Value *InitScalar) |
| 442 | + /// Create a ConditionalScalarAssignmentDescriptor that models a valid |
| 443 | + /// conditional scalar assignment with its members initialized correctly. |
| 444 | + ConditionalScalarAssignmentDescriptor(PHINode *Phi, Instruction *Assignment, |
| 445 | + Value *InitScalar) |
444 | 446 | : Phi(Phi), InitScalar(InitScalar), Assignment(Assignment) {} |
445 | 447 |
|
446 | 448 | public: |
447 | | - /// Create a CSA Descriptor that models an invalid CSA. |
448 | | - CSADescriptor() = default; |
449 | | - |
450 | | - /// If Phi is the root of a CSA, set CSADesc as the CSA rooted by |
451 | | - /// Phi. Otherwise, return a false, leaving CSADesc unmodified. |
452 | | - static bool isCSAPhi(PHINode *Phi, Loop *TheLoop, CSADescriptor &CSADesc); |
| 449 | + /// Create a ConditionalScalarAssignmentDescriptor that models an invalid |
| 450 | + /// ConditionalScalarAssignment. |
| 451 | + ConditionalScalarAssignmentDescriptor() = default; |
| 452 | + |
| 453 | + /// If Phi is the root of a ConditionalScalarAssignment, set |
| 454 | + /// ConditionalScalarAssignmentDesc as the ConditionalScalarAssignment rooted |
| 455 | + /// by Phi. Otherwise, return a false, leaving ConditionalScalarAssignmentDesc |
| 456 | + /// unmodified. |
| 457 | + static bool |
| 458 | + isConditionalScalarAssignmentPhi(PHINode *Phi, Loop *TheLoop, |
| 459 | + ConditionalScalarAssignmentDescriptor &Desc); |
453 | 460 |
|
454 | 461 | operator bool() const { return isValid(); } |
455 | 462 |
|
456 | | - /// Returns whether SI is the Assignment in CSA |
457 | | - static bool isCSASelect(CSADescriptor Desc, SelectInst *SI) { |
| 463 | + /// Returns whether SI is the Assignment in ConditionalScalarAssignment |
| 464 | + static bool isConditionalScalarAssignmentSelect( |
| 465 | + ConditionalScalarAssignmentDescriptor Desc, SelectInst *SI) { |
458 | 466 | return Desc.getAssignment() == SI; |
459 | 467 | } |
460 | 468 |
|
461 | | - /// Return whether this CSADescriptor models a valid CSA. |
| 469 | + /// Return whether this ConditionalScalarAssignmentDescriptor models a valid |
| 470 | + /// ConditionalScalarAssignment. |
462 | 471 | bool isValid() const { return Phi && InitScalar && Assignment; } |
463 | 472 |
|
464 | | - /// Return the PHI that roots this CSA. |
| 473 | + /// Return the PHI that roots this ConditionalScalarAssignment. |
465 | 474 | PHINode *getPhi() const { return Phi; } |
466 | 475 |
|
467 | | - /// Return the initial value of the CSA. This is the value if the conditional |
468 | | - /// assignment does not occur. |
| 476 | + /// Return the initial value of the ConditionalScalarAssignment. This is the |
| 477 | + /// value if the conditional assignment does not occur. |
469 | 478 | Value *getInitScalar() const { return InitScalar; } |
470 | 479 |
|
471 | 480 | /// The Instruction that is used after the loop |
472 | 481 | Instruction *getAssignment() const { return Assignment; } |
473 | 482 |
|
474 | | - /// Return the condition that this CSA is conditional upon. |
| 483 | + /// Return the condition that this ConditionalScalarAssignment is conditional |
| 484 | + /// upon. |
475 | 485 | Value *getCond() const { |
476 | 486 | if (auto *SI = dyn_cast_or_null<SelectInst>(Assignment)) |
477 | 487 | return SI->getCondition(); |
|
0 commit comments