[llvm] [AMDGPU] - Add constant folding to s_wqm intrinsic (PR #72382)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 15 05:43:19 PST 2023
================
@@ -2422,6 +2423,21 @@ static Constant *ConstantFoldScalarCall1(StringRef Name,
return ConstantFP::get(Ty->getContext(), Val);
}
+
+ case Intrinsic::amdgcn_s_wqm: {
+ uint64_t Val = Op->getZExtValue();
+ uint64_t WQM = 0;
+ uint64_t Quad = 0xF;
+ for (unsigned i = 0; i < Op->getBitWidth() / 4;
----------------
jayfoad wrote:
Upper case `I`.
As an alternative, you could implement this one with just two rounds of bit twiddling:
```
Val |= (Val & 0x5555555555555555) << 1| ((Val >> 1) & 0x5555555555555555);
Val |= (Val & 0x3333333333333333) << 2| ((Val >> 2) & 0x3333333333333333);
```
https://github.com/llvm/llvm-project/pull/72382
More information about the llvm-commits
mailing list