[llvm] [InstCombine] Implement `fcmp (fadd x, 0.0), y` => `fcmp x, y` optimization (PR #88476)
Vlad Mishel via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 12 19:08:50 PDT 2024
================
@@ -8100,6 +8100,13 @@ Instruction *InstCombinerImpl::visitFCmpInst(FCmpInst &I) {
return new FCmpInst(I.getSwappedPredicate(), X, NegC, "", &I);
}
+ // fcmp (fadd X, 0.0), Y --> fcmp X, Y
+ if (match(Op0, m_FAdd(m_Value(X), m_APFloat(C))) && C->isZero()) {
+ if (match(Op1, m_Value(Y))) {
+ return new FCmpInst(Pred, X, Y, "", &I);
+ }
+ }
----------------
vmishelcs wrote:
> 1. Add a test for `fcmp X, (fadd Y, 0.0)`
>
> 2. Add a vector test for `fcmp (fadd X, <0.0, -0.0>), Y`
>
> 3. Add a test for fast-math flag preservation
Should I write a separate test case for each type of `fcmp` instruction (`ugt`, `ogt`, etc) for each of these? Or is one test case sufficient for each?
https://github.com/llvm/llvm-project/pull/88476
More information about the llvm-commits
mailing list