[llvm] [InstSimplify] Fold expression using basic properties of floor and ceiling function (PR #107107)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 4 08:12:14 PDT 2024
================
@@ -8178,6 +8178,87 @@ static Instruction *foldFCmpFSubIntoFCmp(FCmpInst &I, Instruction *LHSI,
return nullptr;
}
+static Instruction *foldFCmpWithFloorAndCeil(FCmpInst &I,
+ InstCombinerImpl &CI) {
+ Value *LHS = I.getOperand(0), *RHS = I.getOperand(1);
+ const CmpInst::Predicate Pred = I.getPredicate();
+ Type *OpType = LHS->getType();
+
+ // fcmp ole floor(x), x => fcmp ord x, 0
+ // fcmp ogt floor(x), x => false
+ if (match(LHS, m_Intrinsic<Intrinsic::floor>(m_Specific(RHS)))) {
+ if (Pred == FCmpInst::FCMP_OLE ||
+ Pred == FCmpInst::FCMP_ULE &&
----------------
arsenm wrote:
Yes
https://github.com/llvm/llvm-project/pull/107107
More information about the llvm-commits
mailing list