[clang] [llvm] [HLSL] Adding Flatten and Branch if attributes (PR #116331)
Chris B via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 17 08:51:51 PST 2024
================
@@ -2776,19 +2788,23 @@ bool SPIRVInstructionSelector::selectIntrinsic(Register ResVReg,
}
return MIB.constrainAllUses(TII, TRI, RBI);
}
- case Intrinsic::spv_loop_merge:
- case Intrinsic::spv_selection_merge: {
- const auto Opcode = IID == Intrinsic::spv_selection_merge
- ? SPIRV::OpSelectionMerge
- : SPIRV::OpLoopMerge;
- auto MIB = BuildMI(BB, I, I.getDebugLoc(), TII.get(Opcode));
+ case Intrinsic::spv_loop_merge: {
+ auto MIB = BuildMI(BB, I, I.getDebugLoc(), TII.get(SPIRV::OpLoopMerge));
for (unsigned i = 1; i < I.getNumExplicitOperands(); ++i) {
assert(I.getOperand(i).isMBB());
MIB.addMBB(I.getOperand(i).getMBB());
}
MIB.addImm(SPIRV::SelectionControl::None);
return MIB.constrainAllUses(TII, TRI, RBI);
}
+ case Intrinsic::spv_selection_merge: {
+ auto MIB =
+ BuildMI(BB, I, I.getDebugLoc(), TII.get(SPIRV::OpSelectionMerge));
+ assert(I.getOperand(1).isMBB());
----------------
llvm-beanz wrote:
nit: strings added to asserts make it a lot easier to understand and find problems.
```suggestion
assert(I.getOperand(1).isMBB() &&
"operand 1 to spv_selection_merge must be a basic block");
```
https://github.com/llvm/llvm-project/pull/116331
More information about the cfe-commits
mailing list