[llvm] [IR] Add llvm `cmul` intrinsic (PR #140301)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Sun May 18 01:59:18 PDT 2025
================
@@ -199,6 +199,25 @@ static Value *LowerCTLZ(LLVMContext &Context, Value *V, Instruction *IP) {
return LowerCTPOP(Context, V, IP);
}
+/// Emit the code to lower clmul of V1, V2 before the specified instruction IP.
+static Value *LowerCLMUL(LLVMContext &Context, Value *V1, Value *V2, Instruction *IP) {
+
+ IRBuilder<> Builder(IP);
+
+ unsigned BitSize = V1->getType()->getPrimitiveSizeInBits();
+ Value *Res = ConstantInt::get(V1->getType(), 0);
+ Value *Zero = ConstantInt::get(V1->getType(), 0);
+ Value *One = ConstantInt::get(V1->getType(), 1);
+ for (unsigned i = 1; i < BitSize; i <<= 1) {
----------------
jayfoad wrote:
Variable names start with upper case:
```suggestion
for (unsigned I = 1; I < BitSize; I <<= 1) {
```
Also: does this algorithm really work? It seems like it would need to iterate `BitSize` times, not just `log2(BitSize)` times.
Also, you need some lit test that shows the code generated by this algorithm.
https://github.com/llvm/llvm-project/pull/140301
More information about the llvm-commits
mailing list