[llvm] [InstCombine] Fold expression using basic properties of floor and ceiling function (PR #107107)
    via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Wed Sep  4 23:37:21 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))) {
----------------
c8ef wrote:
Done. The culmination of all 16 transformations results in a timeout. By disabling either the first half or the second half, you can observe the expected outcome.
https://github.com/llvm/llvm-project/pull/107107
    
    
More information about the llvm-commits
mailing list