aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib
diff options
context:
space:
mode:
authorYingwei Zheng <dtcxzyw2333@gmail.com>2024-04-23 19:35:15 +0800
committerGitHub <noreply@github.com>2024-04-23 19:35:15 +0800
commit9fb7a736f0f893ffd5da3cebaed30bc91e6a8514 (patch)
tree91c35f87212b22070ea8bb2ef8e5b0ecce2aa950 /llvm/lib
parentb8174512111bc116776de24e2cff3f6f94d536fe (diff)
downloadllvm-9fb7a736f0f893ffd5da3cebaed30bc91e6a8514.zip
llvm-9fb7a736f0f893ffd5da3cebaed30bc91e6a8514.tar.gz
llvm-9fb7a736f0f893ffd5da3cebaed30bc91e6a8514.tar.bz2
[InstCombine] Fold fcmp into select (#86482)
This patch simplifies `fcmp (select Cond, C1, C2), C3` patterns in ceres: Alive2: https://alive2.llvm.org/ce/z/fWh_sD ``` define i1 @src(double %x) { %cmp1 = fcmp ord double %x, 0.000000e+00 %sel = select i1 %cmp1, double 0xFFFFFFFFFFFFFFFF, double 0.000000e+00 %cmp2 = fcmp oeq double %sel, 0.000000e+00 ret i1 %cmp2 } define i1 @tgt(double %x) { %cmp1 = fcmp uno double %x, 0.000000e+00 ret i1 %cmp1 } ```
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index f0278f2..c2062ad 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -8052,6 +8052,8 @@ Instruction *InstCombinerImpl::visitFCmpInst(FCmpInst &I) {
m_Select(m_Value(), m_Value(X), m_FNeg(m_Deferred(X)))) ||
match(LHSI, m_Select(m_Value(), m_FNeg(m_Value(X)), m_Deferred(X)))))
return replaceOperand(I, 0, X);
+ if (Instruction *NV = FoldOpIntoSelect(I, cast<SelectInst>(LHSI)))
+ return NV;
break;
case Instruction::PHI:
if (Instruction *NV = foldOpIntoPhi(I, cast<PHINode>(LHSI)))