[llvm] [InstCombine] Add missing fold for `fsqrt(select(b, c1, c2)) => select(b, fsqrt(c1), fsqrt(c2))` (PR #113084)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 20 07:07:31 PDT 2024
================
@@ -1699,6 +1699,17 @@ Instruction *InstCombinerImpl::FoldOpIntoSelect(Instruction &Op, SelectInst *SI,
if (SI->getType()->isIntOrIntVectorTy(1))
return nullptr;
+ if (auto *II = dyn_cast<IntrinsicInst>(&Op)) {
+ if (II->getIntrinsicID() == Intrinsic::sqrt) {
+ Value *NewTV = Builder.CreateUnaryIntrinsic(Intrinsic::sqrt, TV, nullptr,
+ "sqrt_fold");
+ Value *NewFV = Builder.CreateUnaryIntrinsic(Intrinsic::sqrt, FV, nullptr,
+ "sqrt_fold");
----------------
arsenm wrote:
Don't bother naming these values.
You should also be able to preserve at least some of the flags
https://github.com/llvm/llvm-project/pull/113084
More information about the llvm-commits
mailing list