[PATCH] D86726: [InstCombine]: Transform 1.0/sqrt(X) * X to X/sqrt(X) and X * 1.0/sqrt(X) to X/sqrt(X)
Noel Grandin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 28 01:25:03 PDT 2020
grandinj added inline comments.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp:552
+
+ // X * 1.0/sqrt(X) = X/sqrt(X).
+ if (match(Op1, (m_FDiv(m_SpecificFP(1.0), m_Value(Y)))) &&
----------------
venkataramanan.kumar.llvm wrote:
> grandinj wrote:
> > Just a drive-by commentator: I am surprised there is not an existing transform which does
> > 1 * X ==> X
> > X * 1 ==> X
> > X / 1 ==> X
> Yes they are available.
>
> This one is specifically targeting the pattern where one operand for multiplication is X and the other operand is Divide. The dividend is 1.0 and divisor is sqrt(x).
>
> x * 1/sqrt(x) ==> x/sqrt(x) later on we try to fold it to sqrt(x) under associative math option.
If they are available, then surely it is not necessary to do
X * 1.0 / sqrt(X) ==> X/sqrt(X).
Surely by the time it gets there, that would already have been folded to
X / sqrt(X)
?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D86726/new/
https://reviews.llvm.org/D86726
More information about the llvm-commits
mailing list