[llvm] [InstCombine] Remove redundant fptrunc of select fold (NFCI) (PR #117182)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 21 08:25:09 PST 2024
https://github.com/nikic created https://github.com/llvm/llvm-project/pull/117182
This was subsumed by FoldOpIntoSelect() in #116073, and has incorrect FMF propagation on top.
>From 5075af7e3ce80ce34c2995a4c29e07052e1debd9 Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov at redhat.com>
Date: Thu, 21 Nov 2024 17:23:24 +0100
Subject: [PATCH] [InstCombine] Remove redundant fptrunc of select fold (NFCI)
This was subsumed by FoldOpIntoSelect() in #116073, and has
incorrect FMF propagation on top.
---
.../InstCombine/InstCombineCasts.cpp | 18 ------------------
1 file changed, 18 deletions(-)
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
index 6c2554ea73b7f8..c97be6ffc75675 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -1866,24 +1866,6 @@ Instruction *InstCombinerImpl::visitFPTrunc(FPTruncInst &FPT) {
return UnaryOperator::CreateFNegFMF(InnerTrunc, Op);
}
-
- // If we are truncating a select that has an extended operand, we can
- // narrow the other operand and do the select as a narrow op.
- Value *Cond, *X, *Y;
- if (match(Op, m_Select(m_Value(Cond), m_FPExt(m_Value(X)), m_Value(Y))) &&
- X->getType() == Ty) {
- // fptrunc (select Cond, (fpext X), Y --> select Cond, X, (fptrunc Y)
- Value *NarrowY = Builder.CreateFPTrunc(Y, Ty);
- Value *Sel = Builder.CreateSelect(Cond, X, NarrowY, "narrow.sel", Op);
- return replaceInstUsesWith(FPT, Sel);
- }
- if (match(Op, m_Select(m_Value(Cond), m_Value(Y), m_FPExt(m_Value(X)))) &&
- X->getType() == Ty) {
- // fptrunc (select Cond, Y, (fpext X) --> select Cond, (fptrunc Y), X
- Value *NarrowY = Builder.CreateFPTrunc(Y, Ty);
- Value *Sel = Builder.CreateSelect(Cond, NarrowY, X, "narrow.sel", Op);
- return replaceInstUsesWith(FPT, Sel);
- }
}
if (auto *II = dyn_cast<IntrinsicInst>(FPT.getOperand(0))) {
More information about the llvm-commits
mailing list