@@ -220,7 +220,7 @@ const ConvergenceRegion *getRegionForHeader(const ConvergenceRegion *Node,
220
220
}
221
221
222
222
// Returns the single BasicBlock exiting the convergence region `CR`,
223
- // nullptr if no such exit exists. F must be the function CR belongs to.
223
+ // nullptr if no such exit exists.
224
224
BasicBlock *getExitFor (const ConvergenceRegion *CR) {
225
225
std::unordered_set<BasicBlock *> ExitTargets;
226
226
for (BasicBlock *Exit : CR->Exits ) {
@@ -285,7 +285,7 @@ bool hasLoopMergeInstruction(BasicBlock &BB) {
285
285
return false ;
286
286
}
287
287
288
- // Returns truye is I is an OpSelectionMerge or OpLoopMerge instruction, false
288
+ // Returns true is I is an OpSelectionMerge or OpLoopMerge instruction, false
289
289
// otherwise.
290
290
bool isMergeInstruction (Instruction *I) {
291
291
return getDesignatedMergeBlock (I) != nullptr ;
@@ -413,7 +413,7 @@ void replaceIfBranchTargets(BasicBlock *BB, BasicBlock *OldTarget,
413
413
C->destroyConstant ();
414
414
}
415
415
416
- // Replaces the branching instruction destination of |BB| by |NewTarget| if it
416
+ // Replaces the target of branch instruction in |BB| with |NewTarget| if it
417
417
// was |OldTarget|. This function also fixes the associated merge instruction.
418
418
// Note: this function does not simplify branching instructions, it only updates
419
419
// targets. See also: simplifyBranches.
@@ -438,7 +438,7 @@ void replaceBranchTargets(BasicBlock *BB, BasicBlock *OldTarget,
438
438
}
439
439
440
440
// Replaces basic bloc operands |OldSrc| or OpPhi instructions in |BB| by
441
- // |NewSrc|. This function does not simplifies the OpPhi instruction once
441
+ // |NewSrc|. This function does not simplify the OpPhi instruction once
442
442
// transformed.
443
443
void replacePhiTargets (BasicBlock *BB, BasicBlock *OldSrc, BasicBlock *NewSrc) {
444
444
for (PHINode &Phi : BB->phis ()) {
@@ -462,8 +462,8 @@ class SPIRVStructurizer : public FunctionPass {
462
462
using ConstructList = std::vector<std::unique_ptr<DivergentConstruct>>;
463
463
464
464
// Represents a divergent construct in the SPIR-V sense.
465
- // Such construct is represented by a header (entry), a merge block (exit),
466
- // and possible a continue block (back-edge). Each construct can contain other
465
+ // Such constructs are represented by a header (entry), a merge block (exit),
466
+ // and possibly a continue block (back-edge). A construct can contain other
467
467
// constructs, but their boundaries do not cross.
468
468
struct DivergentConstruct {
469
469
BasicBlock *Header = nullptr ;
@@ -491,13 +491,12 @@ class SPIRVStructurizer : public FunctionPass {
491
491
DT.recalculate (F);
492
492
}
493
493
494
- // Returns the list of blocks that belongs to a SPIR-V continue construct.
494
+ // Returns the list of blocks that belong to a SPIR-V continue construct.
495
495
std::vector<BasicBlock *> getContinueConstructBlocks (BasicBlock *Header,
496
496
BasicBlock *Continue) {
497
497
std::vector<BasicBlock *> Output;
498
498
Loop *L = LI.getLoopFor (Continue);
499
- BasicBlock *BackEdgeBlock = L->getLoopLatch ();
500
- assert (BackEdgeBlock);
499
+ assert (L->getLoopLatch () != nullptr );
501
500
502
501
partialOrderVisit (*Continue, [&](BasicBlock *BB) {
503
502
if (BB == Header)
@@ -508,7 +507,7 @@ class SPIRVStructurizer : public FunctionPass {
508
507
return Output;
509
508
}
510
509
511
- // Returns the list of blocks that belongs to a SPIR-V loop construct.
510
+ // Returns the list of blocks that belong to a SPIR-V loop construct.
512
511
std::vector<BasicBlock *> getLoopConstructBlocks (BasicBlock *Header,
513
512
BasicBlock *Merge,
514
513
BasicBlock *Continue) {
@@ -525,7 +524,7 @@ class SPIRVStructurizer : public FunctionPass {
525
524
return Output;
526
525
}
527
526
528
- // Returns the list of blocks that belongs to a SPIR-V selection construct.
527
+ // Returns the list of blocks that belong to a SPIR-V selection construct.
529
528
std::vector<BasicBlock *>
530
529
getSelectionConstructBlocks (DivergentConstruct *Node) {
531
530
assert (DT.dominates (Node->Header , Node->Merge ));
@@ -551,7 +550,7 @@ class SPIRVStructurizer : public FunctionPass {
551
550
return Output;
552
551
}
553
552
554
- // Returns the list of blocks that belongs to a SPIR-V switch construct.
553
+ // Returns the list of blocks that belong to a SPIR-V switch construct.
555
554
std::vector<BasicBlock *> getSwitchConstructBlocks (BasicBlock *Header,
556
555
BasicBlock *Merge) {
557
556
assert (DT.dominates (Header, Merge));
@@ -571,7 +570,7 @@ class SPIRVStructurizer : public FunctionPass {
571
570
return Output;
572
571
}
573
572
574
- // Returns the list of blocks that belongs to a SPIR-V case construct.
573
+ // Returns the list of blocks that belong to a SPIR-V case construct.
575
574
std::vector<BasicBlock *> getCaseConstructBlocks (BasicBlock *Target,
576
575
BasicBlock *Merge) {
577
576
assert (DT.dominates (Target, Merge));
@@ -597,12 +596,12 @@ class SPIRVStructurizer : public FunctionPass {
597
596
//
598
597
// clang-format off
599
598
//
600
- // In SPIR-V, construct must have a single exit/merge.
601
- // Given A, B nodes in the construct, a C a node outside, with the following edges.
599
+ // In SPIR-V, constructs must have a single exit/merge.
600
+ // Given nodes A and B in the construct, a node C outside, and the following edges.
602
601
// A -> C
603
602
// B -> C
604
603
//
605
- // In such cases, we must create a new exit node D, that belongs to the construct to make is viable:
604
+ // In such cases, we must create a new exit node D, that belong to the construct to make is viable:
606
605
// A -> D -> C
607
606
// B -> D -> C
608
607
//
@@ -839,11 +838,11 @@ class SPIRVStructurizer : public FunctionPass {
839
838
return Modified;
840
839
}
841
840
842
- // When a block has multiple OpSelectionMerge/OpLoopMerge, sorts those
843
- // instructions to but the "largest" first. A merge instruction is defined as
844
- // larger than another when its target merge block post-dominates the other
845
- // target's merge block.
846
- // (This ordering should match the nesting ordering of the source HLSL).
841
+ // When a block has multiple OpSelectionMerge/OpLoopMerge instructions , sorts
842
+ // them to put the "largest" first. A merge instruction is defined as larger
843
+ // than another when its target merge block post-dominates the other target's
844
+ // merge block. (This ordering should match the nesting ordering of the source
845
+ // HLSL).
847
846
bool sortSelectionMerge (Function &F, BasicBlock &Block) {
848
847
std::vector<Instruction *> MergeInstructions;
849
848
for (Instruction &I : Block)
@@ -1159,8 +1158,8 @@ class SPIRVStructurizer : public FunctionPass {
1159
1158
return Modified;
1160
1159
}
1161
1160
1162
- // Makes sure every case target in |F| are unique. If 2 case branch to the
1163
- // same basic block, one of the target is updated so it jumps to a new basic
1161
+ // Makes sure every case target in |F| is unique. If 2 cases branch to the
1162
+ // same basic block, one of the targets is updated so it jumps to a new basic
1164
1163
// block ending with a single unconditional branch to the original target.
1165
1164
bool splitSwitchCases (Function &F) {
1166
1165
bool Modified = false ;
0 commit comments