[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
Mon May 20 06:52:10 PDT 2024
================
@@ -8037,6 +8037,46 @@ Instruction *InstCombinerImpl::visitFCmpInst(FCmpInst &I) {
if (Instruction *NV = FoldOpIntoSelect(I, cast<SelectInst>(LHSI)))
return NV;
break;
+ case Instruction::FSub:
+ switch (Pred) {
+ default:
+ break;
+ case FCmpInst::FCMP_UGT:
+ case FCmpInst::FCMP_ULT:
+ case FCmpInst::FCMP_UNE:
+ case FCmpInst::FCMP_OEQ:
+ case FCmpInst::FCMP_OGE:
+ case FCmpInst::FCMP_OLE:
+ // Skip optimization: fsub x, y unless guaranteed !isinf(x) ||
+ // !isinf(y).
+ if (!LHSI->hasOneUse() ||
----------------
arsenm wrote:
Instead of duplicating the hasOneUse check, you could hoist the whole inner pattern match below before the condition type handling. It would also probably be nicer to read splitting the whole switch into a helper function
https://github.com/llvm/llvm-project/pull/85506
More information about the llvm-commits
mailing list