[PATCH] D153047: [AMDGPU] Stop replacing amdgcn.ballot(1) with amdgcn.s.getreg(exec)
Jay Foad via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 15 09:54:30 PDT 2023
foad created this revision.
foad added reviewers: AMDGPU, sebastian-ne, nhaehnle.
Herald added subscribers: StephenFan, kerbowa, hiraditya, tpr, dstuttard, yaxunl, jvesely, kzhuravl, arsenm.
Herald added a project: All.
foad requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.
Rationale:
- It does not enable any further IR simplifications.
- It does not improve the generated code since the isel lowering of ballot also has special cases for 0 and 1.
- getreg is "too powerful" since it can read from many different registers, so its intrinsic properties have to be set very conservatively.
There is also a correctness problem that getreg can read from exec but
it is currently not marked as convergent.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D153047
Files:
llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll
Index: llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll
===================================================================
--- llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll
+++ llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll
@@ -2582,7 +2582,7 @@
define i64 @ballot_one_64() {
; CHECK-LABEL: @ballot_one_64(
-; CHECK-NEXT: [[B:%.*]] = call i64 @llvm.read_register.i64(metadata [[META0]]) #[[ATTR17]]
+; CHECK-NEXT: [[B:%.*]] = call i64 @llvm.amdgcn.ballot.i64(i1 true)
; CHECK-NEXT: ret i64 [[B]]
;
%b = call i64 @llvm.amdgcn.ballot.i64(i1 1)
@@ -2608,7 +2608,7 @@
define i32 @ballot_one_32() {
; CHECK-LABEL: @ballot_one_32(
-; CHECK-NEXT: [[B:%.*]] = call i32 @llvm.read_register.i32(metadata [[META1:![0-9]+]]) #[[ATTR17]]
+; CHECK-NEXT: [[B:%.*]] = call i32 @llvm.amdgcn.ballot.i32(i1 true)
; CHECK-NEXT: ret i32 [[B]]
;
%b = call i32 @llvm.amdgcn.ballot.i32(i1 1)
Index: llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
@@ -908,25 +908,6 @@
// amdgcn.ballot(i1 0) is zero.
return IC.replaceInstUsesWith(II, Constant::getNullValue(II.getType()));
}
-
- if (Src->isOne()) {
- // amdgcn.ballot(i1 1) is exec.
- const char *RegName = "exec";
- if (II.getType()->isIntegerTy(32))
- RegName = "exec_lo";
- else if (!II.getType()->isIntegerTy(64))
- break;
-
- Function *NewF = Intrinsic::getDeclaration(
- II.getModule(), Intrinsic::read_register, II.getType());
- Metadata *MDArgs[] = {MDString::get(II.getContext(), RegName)};
- MDNode *MD = MDNode::get(II.getContext(), MDArgs);
- Value *Args[] = {MetadataAsValue::get(II.getContext(), MD)};
- CallInst *NewCall = IC.Builder.CreateCall(NewF, Args);
- NewCall->addFnAttr(Attribute::Convergent);
- NewCall->takeName(&II);
- return IC.replaceInstUsesWith(II, NewCall);
- }
}
break;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153047.531805.patch
Type: text/x-patch
Size: 2160 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230615/af6bbb1e/attachment.bin>
More information about the llvm-commits
mailing list