[llvm] [AMDGPU] - Add constant folding for s_bitreplicate (PR #72366)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 15 01:44:31 PST 2023
================
@@ -2422,6 +2423,23 @@ static Constant *ConstantFoldScalarCall1(StringRef Name,
return ConstantFP::get(Ty->getContext(), Val);
}
+
+ case Intrinsic::amdgcn_s_bitreplicate: {
+ uint64_t Val = Op->getZExtValue();
+ uint64_t ReplicatedVal = 0;
+ uint64_t ReplicatedOnes = 0b11;
+ // Input operand is always b32
+ for (unsigned i = 0; i < 32; ++i, ReplicatedOnes <<= 2, Val >>= 1) {
+ uint64_t Bit = Val & 1;
----------------
jayfoad wrote:
Nit: could fold this into the only use of `Bit`.
https://github.com/llvm/llvm-project/pull/72366
More information about the llvm-commits
mailing list