[PATCH] D30527: Replacing float with new class Fraction for LSR alternative way of resolving complex solution

Quentin Colombet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 7 16:01:04 PST 2017


qcolombet added inline comments.


================
Comment at: lib/Transforms/Scalar/LoopStrengthReduce.cpp:1069
+  uint64_t Denominator;
+  Fraction &Optimize() {
+    while (Numerator > UINT32_MAX / 2 || Denominator > UINT32_MAX / 2) {
----------------
Could you add a comment explaining how the optimization work?
The reduction does not look right to me, but my math class are way behind me :P


================
Comment at: lib/Transforms/Scalar/LoopStrengthReduce.cpp:1082
+  Fraction() : Numerator(0), Denominator(1) {}
+  Fraction(unsigned N, unsigned D) : Numerator(N), Denominator(D) {}
+  Fraction operator/(const Fraction &Divider) const {
----------------
Add an assert D != 0


================
Comment at: lib/Transforms/Scalar/LoopStrengthReduce.cpp:1087
+    Res.Denominator = Denominator / Divider.Denominator;
+    return Res;
+  }
----------------
I am confused about the meaning of this operator.
For divide, I would have expected something like:
return operator*(Fraction(Divider.Denominator, Divider.Numerator));


Repository:
  rL LLVM

https://reviews.llvm.org/D30527





More information about the llvm-commits mailing list