[PATCH] D87479: [InstCombine] Don't sink the fdiv from (fmul (fdiv 1.0, %x), %y) if the fdiv isn't in the same basic block as the fmul
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 10 12:59:58 PST 2023
craig.topper added inline comments.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp:531
- Value *Z;
- if (match(&I, m_c_FMul(m_OneUse(m_FDiv(m_Value(X), m_Value(Y))),
- m_Value(Z)))) {
- // Sink division: (X / Y) * Z --> (X * Z) / Y
- Value *NewFMul = Builder.CreateFMulFMF(X, Z, &I);
+ // Sink division: (X / Y) * Z --> (X * Z) / Y
+ // Don't sink if the fdiv is a reciprocal in a different basic block as this
----------------
I found another variation of this
(X/Y) outside loop
Mul with Z inside loop.
->
X*Z ends up inside loop
/ Y ends up in loop
->
recip of Y outside loop
X*Z in loop
mul with reciprocal of Y inside loop.
So we went from an fdiv outside loop and one fmul inside the loop to 1 div outside the loop and 2 fmuls inside the loop.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D87479/new/
https://reviews.llvm.org/D87479
More information about the llvm-commits
mailing list