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

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 22 06:06:55 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))
----------------
dtcxzyw wrote:

We can use FMF flags to further fold expressions in `InstSimplifyFolder`.
E.g., `minimum(X, -inf) -> -inf when FMF nnan is set`.


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


More information about the llvm-commits mailing list