[llvm] [InstCombine] Fold expression using basic properties of floor and ceiling function (PR #107107)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 4 19:07:59 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 &&
+ isKnownNeverNaN(LHS, 0,
+ CI.getSimplifyQuery().getWithInstruction(&I))) {
----------------
dtcxzyw wrote:
Please update the alive2 link in your PR description.
https://github.com/llvm/llvm-project/pull/107107
More information about the llvm-commits
mailing list