[llvm] [AMDGPU] Remove always-true icmp/fcmp instcombine fold to EXEC read (PR #201358)
Arseniy Obolenskiy via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 3 07:15:38 PDT 2026
================
@@ -1644,15 +1644,19 @@ GCNTTIImpl::instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const {
// intrinsic exposes) is one bit per thread, masked with the EXEC
// register (which contains the bitmask of live threads). So a
// comparison that always returns true is the same as a read of the
- // EXEC register.
- Metadata *MDArgs[] = {MDString::get(II.getContext(), "exec")};
+ // EXEC register. EXEC is wave-size bits wide, so read it at that width
+ // and zext/trunc to the return type.
+ Type *ExecTy = IC.Builder.getIntNTy(ST->getWavefrontSize());
+ StringRef ExecName = ST->isWave32() ? "exec_lo" : "exec";
+ Metadata *MDArgs[] = {MDString::get(II.getContext(), ExecName)};
MDNode *MD = MDNode::get(II.getContext(), MDArgs);
Value *Args[] = {MetadataAsValue::get(II.getContext(), MD)};
- CallInst *NewCall = IC.Builder.CreateIntrinsic(Intrinsic::read_register,
- II.getType(), Args);
+ CallInst *NewCall =
+ IC.Builder.CreateIntrinsic(Intrinsic::read_register, ExecTy, Args);
----------------
aobolensk wrote:
I have removed the code, please re-check
https://github.com/llvm/llvm-project/pull/201358
More information about the llvm-commits
mailing list