[clang] [llvm] [HLSL] Adding Flatten and Branch if attributes (PR #116331)
Chris B via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 2 12:20:59 PST 2024
================
@@ -2694,19 +2694,49 @@ 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 SelectionControl = SPIRV::SelectionControl::None;
+ auto LastOp = I.getOperand(I.getNumExplicitOperands() - 1);
----------------
llvm-beanz wrote:
This code still makes an assumption that if metadata is present on this instruction it must be HLSL branch metadata... That seems like an unsafe assumption to make. Shouldn't we force that we're reading the `hlsl.controlflow.hint` metadata.
https://github.com/llvm/llvm-project/pull/116331
More information about the cfe-commits
mailing list