aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/AMDGPU/AMDGPULowerKernelAttributes.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Target/AMDGPU/AMDGPULowerKernelAttributes.cpp')
-rw-r--r--llvm/lib/Target/AMDGPU/AMDGPULowerKernelAttributes.cpp38
1 files changed, 14 insertions, 24 deletions
diff --git a/llvm/lib/Target/AMDGPU/AMDGPULowerKernelAttributes.cpp b/llvm/lib/Target/AMDGPU/AMDGPULowerKernelAttributes.cpp
index 08a1b970648d..f5903b3afb81 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPULowerKernelAttributes.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPULowerKernelAttributes.cpp
@@ -163,39 +163,29 @@ static bool processUse(CallInst *CI) {
if (!GroupSize || !GridSize)
continue;
+ using namespace llvm::PatternMatch;
+ auto GroupIDIntrin =
+ I == 0 ? m_Intrinsic<Intrinsic::amdgcn_workgroup_id_x>()
+ : (I == 1 ? m_Intrinsic<Intrinsic::amdgcn_workgroup_id_y>()
+ : m_Intrinsic<Intrinsic::amdgcn_workgroup_id_z>());
+
for (User *U : GroupSize->users()) {
auto *ZextGroupSize = dyn_cast<ZExtInst>(U);
if (!ZextGroupSize)
continue;
- for (User *ZextUser : ZextGroupSize->users()) {
- auto *SI = dyn_cast<SelectInst>(ZextUser);
- if (!SI)
- continue;
-
- using namespace llvm::PatternMatch;
- auto GroupIDIntrin = I == 0 ?
- m_Intrinsic<Intrinsic::amdgcn_workgroup_id_x>() :
- (I == 1 ? m_Intrinsic<Intrinsic::amdgcn_workgroup_id_y>() :
- m_Intrinsic<Intrinsic::amdgcn_workgroup_id_z>());
-
- auto SubExpr = m_Sub(m_Specific(GridSize),
- m_Mul(GroupIDIntrin, m_Specific(ZextGroupSize)));
-
- ICmpInst::Predicate Pred;
- if (match(SI,
- m_Select(m_ICmp(Pred, SubExpr, m_Specific(ZextGroupSize)),
- SubExpr,
- m_Specific(ZextGroupSize))) &&
- Pred == ICmpInst::ICMP_ULT) {
+ for (User *UMin : ZextGroupSize->users()) {
+ if (match(UMin,
+ m_UMin(m_Sub(m_Specific(GridSize),
+ m_Mul(GroupIDIntrin, m_Specific(ZextGroupSize))),
+ m_Specific(ZextGroupSize)))) {
if (HasReqdWorkGroupSize) {
ConstantInt *KnownSize
= mdconst::extract<ConstantInt>(MD->getOperand(I));
- SI->replaceAllUsesWith(ConstantExpr::getIntegerCast(KnownSize,
- SI->getType(),
- false));
+ UMin->replaceAllUsesWith(ConstantExpr::getIntegerCast(
+ KnownSize, UMin->getType(), false));
} else {
- SI->replaceAllUsesWith(ZextGroupSize);
+ UMin->replaceAllUsesWith(ZextGroupSize);
}
MadeChange = true;