Skip to content

Commit ac44b3b

Browse files
author
joaosaffran
committed
addressing comments
1 parent d1764e1 commit ac44b3b

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

clang/lib/CodeGen/CodeGenFunction.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2100,8 +2100,6 @@ void CodeGenFunction::EmitBranchOnBoolExpr(
21002100
BrInst->setMetadata("hlsl.controlflow.hint",
21012101
llvm::MDNode::get(CGM.getLLVMContext(), Vals));
21022102
} break;
2103-
case HLSLControlFlowHintAttr::SpellingNotCalculated:
2104-
break;
21052103
}
21062104
}
21072105

llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "llvm/CodeGen/TargetOpcodes.h"
3434
#include "llvm/IR/IntrinsicsSPIRV.h"
3535
#include "llvm/Support/Debug.h"
36+
#include "llvm/Support/ErrorHandling.h"
3637

3738
#define DEBUG_TYPE "spirv-isel"
3839

@@ -45,6 +46,17 @@ using ExtInstList =
4546

4647
namespace {
4748

49+
llvm::SPIRV::SelectionControl::SelectionControl
50+
getSelectionOperandForImm(int Imm) {
51+
if (Imm == 2)
52+
return SPIRV::SelectionControl::Flatten;
53+
if (Imm == 1)
54+
return SPIRV::SelectionControl::DontFlatten;
55+
if (Imm == 0)
56+
return SPIRV::SelectionControl::None;
57+
llvm_unreachable("Invalid immediate");
58+
}
59+
4860
#define GET_GLOBALISEL_PREDICATE_BITSET
4961
#include "SPIRVGenGlobalISel.inc"
5062
#undef GET_GLOBALISEL_PREDICATE_BITSET
@@ -2786,23 +2798,11 @@ bool SPIRVInstructionSelector::selectIntrinsic(Register ResVReg,
27862798
return MIB.constrainAllUses(TII, TRI, RBI);
27872799
}
27882800
case Intrinsic::spv_selection_merge: {
2789-
2790-
int64_t SelectionControl = SPIRV::SelectionControl::None;
2791-
auto LastOp = I.getOperand(I.getNumOperands() - 1);
2792-
2793-
auto BranchHint = LastOp.getImm();
2794-
if (BranchHint == 2)
2795-
SelectionControl = SPIRV::SelectionControl::Flatten;
2796-
else if (BranchHint == 1)
2797-
SelectionControl = SPIRV::SelectionControl::DontFlatten;
2798-
27992801
auto MIB =
28002802
BuildMI(BB, I, I.getDebugLoc(), TII.get(SPIRV::OpSelectionMerge));
2801-
for (unsigned i = 1; i < I.getNumExplicitOperands() - 1; ++i) {
2802-
assert(I.getOperand(i).isMBB());
2803-
MIB.addMBB(I.getOperand(i).getMBB());
2804-
}
2805-
MIB.addImm(SelectionControl);
2803+
assert(I.getOperand(1).isMBB());
2804+
MIB.addMBB(I.getOperand(1).getMBB());
2805+
MIB.addImm(getSelectionOperandForImm(I.getOperand(2).getImm()));
28062806
return MIB.constrainAllUses(TII, TRI, RBI);
28072807
}
28082808
case Intrinsic::spv_cmpxchg:

0 commit comments

Comments
 (0)