[llvm] [InstCombine] Fold fcmp ogt (x - y), 0 into fcmp ogt x, y #85245 (PR #85506)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 22 05:13:05 PDT 2024
================
@@ -7972,6 +7972,11 @@ Instruction *InstCombinerImpl::visitFCmpInst(FCmpInst &I) {
Constant *RHSC;
if (match(Op0, m_Instruction(LHSI)) && match(Op1, m_Constant(RHSC))) {
switch (LHSI->getOpcode()) {
+ case Instruction::FSub:
+ if (Pred == FCmpInst::FCMP_OGT && match(RHSC, m_PosZeroFP()) &&
----------------
arsenm wrote:
For the tests you have written here, yes it will always fail. You will need to have additional tests covering the no-infinity knowledge.
Also, you're not taking advantage of the fast math flags on the fsub itself by directly looking at the operands. IIRC there's another overload of isKnownNeverInfinity with passed in flags
https://github.com/llvm/llvm-project/pull/85506
More information about the llvm-commits
mailing list