[llvm] [IRBuilder] Fold binary intrinsics (PR #80743)

Artem Tyurin via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 22 05:56:14 PST 2024


================
@@ -918,10 +918,11 @@ CallInst *IRBuilderBase::CreateUnaryIntrinsic(Intrinsic::ID ID, Value *V,
   return createCallHelper(Fn, {V}, Name, FMFSource);
 }
 
-CallInst *IRBuilderBase::CreateBinaryIntrinsic(Intrinsic::ID ID, Value *LHS,
-                                               Value *RHS,
-                                               Instruction *FMFSource,
-                                               const Twine &Name) {
+Value *IRBuilderBase::CreateBinaryIntrinsic(Intrinsic::ID ID, Value *LHS,
+                                            Value *RHS, Instruction *FMFSource,
+                                            const Twine &Name) {
+  if (auto *V = Folder.FoldBinaryIntrinsic(ID, LHS, RHS))
----------------
agentcooper wrote:

It is not immediately clear to me how it can be used, given that `FoldBinaryIntrinsic` returns a `Constant` and from my understanding the `FMFSource` is used to copy FMF flags when a new `CallInst` is created.

https://github.com/llvm/llvm-project/pull/80743


More information about the llvm-commits mailing list