[patch] fix comment on findGCD

Mingjie Xing mingjie.xing at gmail.com
Thu Jan 2 18:09:21 PST 2014


Hello,

2013/12/31 David Tweed <david.tweed at arm.com>:
> Clearly fixing a typo is good: just to be sure, you've verified that the
> definition of the equation whose solution is found is the one with a plus
> rather than
> a minus?

I run the program in gdb with a test case, and figured out that it really should
be a minus. Though, it is a plus in the paper.

> I'm ambivalent about the second line "Return true if dependence disproved."
> Changed, since it doesn't really follow the principle that function
> prototype
> Comments should be understandable without having to look at either the
> Caller context or the function body, and what "dependence" means here
> isn't obvious from the signature.

Actually, the problem here is that the function returns true iff the gcd does't
divide Delta. See the function code below:

  // make sure gcd divides Delta
  R = Delta.srem(G);
  if (R != 0)
    return true; // gcd doesn't divide Delta, no dependence

So, here is an updated patch:

Index: lib/Analysis/DependenceAnalysis.cpp
===================================================================
--- lib/Analysis/DependenceAnalysis.cpp (revision 198188)
+++ lib/Analysis/DependenceAnalysis.cpp (working copy)
@@ -1275,8 +1275,8 @@
 //
 // Program 2.1, page 29.
 // Computes the GCD of AM and BM.
-// Also finds a solution to the equation ax - by = gdc(a, b).
-// Returns true iff the gcd divides Delta.
+// Also finds a solution to the equation ax - by = gcd(a, b).
+// Returns true iff the gcd does't divide Delta.
 static
 bool findGCD(unsigned Bits, APInt AM, APInt BM, APInt Delta,
              APInt &G, APInt &X, APInt &Y) {

OK?

Cheers
Mingjie



More information about the llvm-commits mailing list